Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions mcs/class/corlib/System/TimeZoneInfo.WinRT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ internal struct DYNAMIC_TIME_ZONE_INFORMATION

internal const uint TIME_ZONE_ID_INVALID = 0xffffffff;
internal const uint ERROR_NO_MORE_ITEMS = 259;
internal const uint ERROR_SUCCESS = 0;

[DllImport ("api-ms-win-core-timezone-l1-1-0.dll")]
internal extern static uint EnumDynamicTimeZoneInformation (uint dwIndex, out DYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation);
Expand Down Expand Up @@ -349,7 +350,7 @@ internal static List<TimeZoneInfo> GetSystemTimeZonesWinRTFallback ()
try {
uint index = 0;
DYNAMIC_TIME_ZONE_INFORMATION dtzi;
while (EnumDynamicTimeZoneInformation (index++, out dtzi) != ERROR_NO_MORE_ITEMS) {
while (EnumDynamicTimeZoneInformation (index++, out dtzi) == ERROR_SUCCESS) {
var timeZoneInfo = TryCreateTimeZone (dtzi);
if (timeZoneInfo != null)
result.Add (timeZoneInfo);
Expand All @@ -358,8 +359,6 @@ internal static List<TimeZoneInfo> GetSystemTimeZonesWinRTFallback ()
// EnumDynamicTimeZoneInformation() might not be available.
}

if (result.Count == 0)
result.Add (Local);
return result;
}
}
Expand Down
4 changes: 4 additions & 0 deletions mcs/class/corlib/System/TimeZoneInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,10 @@ public static ReadOnlyCollection<TimeZoneInfo> GetSystemTimeZones ()
if (systemTimeZones == null) {
var tz = new List<TimeZoneInfo> ();
GetSystemTimeZonesCore (tz);
// Don't want to return an empty list if we can help it
// but we don't want to stack overflow via a CreateLocal loop
if (tz.Count == 0 && local != null)
tz.Add(Local);
Interlocked.CompareExchange (ref systemTimeZones, new ReadOnlyCollection<TimeZoneInfo> (tz), null);
}

Expand Down