Skip to content

Commit

Permalink
Merge pull request #1220 from Unity-Technologies/timezone-dst-same-st…
Browse files Browse the repository at this point in the history
…art-end

Handle locales with the same daylight savings time start and end
  • Loading branch information
Joshua Peterson authored Aug 23, 2019
2 parents 03b6860 + af746cd commit b73fd4a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mcs/class/corlib/System/TimeZoneInfo.Unity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ static List<AdjustmentRule> CreateAdjustmentRule (int year, out Int64[] data, ou
if(daylightNameCurrentYear != names[(int)TimeZoneNames.DaylightNameIdx])
return rulesForYear;

// If the first and second transition DateTime objects are the same, ValidateAdjustmentRule will throw
// an exception. I'm unsure why these would be the same, but we do see that occur for some locales.
// In that case, just exit early.
if (firstTransition.Equals(secondTransition))
return rulesForYear;

var beginningOfYear = new DateTime (year, 1, 1, 0, 0, 0, 0);
var endOfYearDay = new DateTime (year, 12, DateTime.DaysInMonth (year, 12));
var endOfYearMaxTimeout = new DateTime (year, 12, DateTime.DaysInMonth(year, 12), 23, 59, 59, 999);
Expand Down

0 comments on commit b73fd4a

Please sign in to comment.