Skip to content

Commit

Permalink
[corlib] Fix TimeZoneInfo.Local when /usr/share/zoneinfo is a symlink (
Browse files Browse the repository at this point in the history
…#8305)

We'd be using the path verbatim to compare with the resolved value of
/etc/localtime but if it's a symlink (like on OSX 10.13+) the comparison failed.

The fix is to resolve any symlinks for /usr/share/zoneinfo too.

Fixes #8267 and xamarin/maccore#628
  • Loading branch information
monojenkins authored and akoeplinger committed Apr 18, 2018
1 parent 32ba15e commit 98a3dd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion mcs/class/corlib/System/TimeZoneInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,12 @@ public static TimeZoneInfo Utc {
}
}
#if LIBC
const string DefaultTimeZoneDirectory = "/usr/share/zoneinfo";
static string timeZoneDirectory;
static string TimeZoneDirectory {
get {
if (timeZoneDirectory == null)
timeZoneDirectory = "/usr/share/zoneinfo";
timeZoneDirectory = readlink (DefaultTimeZoneDirectory) ?? DefaultTimeZoneDirectory;
return timeZoneDirectory;
}
set {
Expand Down
4 changes: 2 additions & 2 deletions mcs/class/corlib/Test/System/TimeZoneInfoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public void LocalId ()
} catch (DllNotFoundException e) {
return;
}
#if !MONOTOUCH && !XAMMAC && !XAMMAC_4_5
// this assumption is incorrect for iOS, tvO, watchOS and OSX
#if !MONOTOUCH && !XAMMAC
// this assumption is incorrect for the TimeZoneInfo.MonoTouch.cs implementation (iOS, tvOS, watchOS and XamMac Modern)
Assert.IsTrue (TimeZoneInfo.Local.Id != "Local", "Local timezone id should not be \"Local\"");
#endif
}
Expand Down

0 comments on commit 98a3dd7

Please sign in to comment.