Skip to content

Commit b73fd4a

Browse files
author
Joshua Peterson
authored
Merge pull request #1220 from Unity-Technologies/timezone-dst-same-start-end
Handle locales with the same daylight savings time start and end
2 parents 03b6860 + af746cd commit b73fd4a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mcs/class/corlib/System/TimeZoneInfo.Unity.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ static List<AdjustmentRule> CreateAdjustmentRule (int year, out Int64[] data, ou
5454
if(daylightNameCurrentYear != names[(int)TimeZoneNames.DaylightNameIdx])
5555
return rulesForYear;
5656

57+
// If the first and second transition DateTime objects are the same, ValidateAdjustmentRule will throw
58+
// an exception. I'm unsure why these would be the same, but we do see that occur for some locales.
59+
// In that case, just exit early.
60+
if (firstTransition.Equals(secondTransition))
61+
return rulesForYear;
62+
5763
var beginningOfYear = new DateTime (year, 1, 1, 0, 0, 0, 0);
5864
var endOfYearDay = new DateTime (year, 12, DateTime.DaysInMonth (year, 12));
5965
var endOfYearMaxTimeout = new DateTime (year, 12, DateTime.DaysInMonth(year, 12), 23, 59, 59, 999);

0 commit comments

Comments
 (0)