Skip to content

Commit

Permalink
Handle locales with the same daylight savings time start and end
Browse files Browse the repository at this point in the history
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.

This change corrects Unity case 1160695.
  • Loading branch information
Josh Peterson committed Aug 23, 2019
1 parent 03b6860 commit af746cd
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 af746cd

Please sign in to comment.