GetOccurrence method
Gets the local wall-clock date and time (as UTC fields) at which this transition
occurs in the specified year.
Implementation
DateTime GetOccurrence(int year) {
final daysInMonth = TimeZoneRuleConverter.DaysInMonth(year, Month);
int day;
if (IsFixedDateRule) {
day = Day > daysInMonth ? daysInMonth : Day;
} else if (Week >= 5) {
final lastWeekday = DateTime.utc(year, Month, daysInMonth).weekday;
day = daysInMonth - ((lastWeekday - DayOfWeek + 7) % 7);
} else {
final firstWeekday = DateTime.utc(year, Month, 1).weekday;
day = 1 + ((DayOfWeek - firstWeekday + 7) % 7) + (Week - 1) * 7;
}
return DateTime.utc(year, Month, day).add(TimeOfDay);
}