Skip to content

Commit af746cd

Browse files
author
Josh Peterson
committed
Handle locales with the same daylight savings time start and end
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.
1 parent 03b6860 commit af746cd

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)