From a7cb29a4b72405e62100babcc14645a6b6fe207f Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Mon, 15 Jul 2019 03:47:11 -0400 Subject: [PATCH] Ensure Local TimeZone Id is Set For TimeZoneInfo.Local (#6564) * Mirrors the runtime change found in https://github.com/mono/mono/pull/15667. The fix here is to return the name of the local time zone so that TimeZoneInfo.Local can have the correct Id. * Added nil check on name. Returns Local as the Id in the case of nil --- runtime/xamarin-support.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/runtime/xamarin-support.m b/runtime/xamarin-support.m index 6ad8dc0584..e8028538f6 100644 --- a/runtime/xamarin-support.m +++ b/runtime/xamarin-support.m @@ -63,6 +63,11 @@ xamarin_log (const unsigned short *unicodeMessage) [msg release]; } +// NOTE: The timezone functions are duplicated in mono, so if you're going to modify here, it would be nice +// if we modify there. +// +// See in Mono sdks/ios/runtime/runtime.m + void* xamarin_timezone_get_data (const char *name, int *size) { @@ -96,6 +101,18 @@ xamarin_timezone_get_names (int *count) return result; } +// +// Returns the geopolitical region ID of the local timezone. + +const char * +xamarin_timezone_get_local_name () +{ + NSTimeZone *tz = nil; + tz = [NSTimeZone localTimeZone]; + NSString *name = [tz name]; + return (name != nil) ? strdup ([name UTF8String]) : strdup ("Local"); +} + #if !TARGET_OS_WATCH && !TARGET_OS_TV void xamarin_start_wwan (const char *uri)