Skip to content

Commit

Permalink
Merge commit 'refs/pull/584/head' of github.com:rianjs/ical.net
Browse files Browse the repository at this point in the history
  • Loading branch information
gonace committed Jan 19, 2024
2 parents 4f7e481 + dc8e767 commit 3f99776
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/Ical.Net/CalendarComponents/VTimeZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,24 @@ public static VTimeZone FromDateTimeZone(string tzId, DateTime earlistDateTimeTo
var vTimeZone = new VTimeZone(tzId);

var earliestYear = 1900;
var earliestMonth = earlistDateTimeToSupport.Month;
var earliestDay = earlistDateTimeToSupport.Day;
// Support date/times for January 1st of the previous year by default.
if (earlistDateTimeToSupport.Year > 1900)
{
earliestYear = earlistDateTimeToSupport.Year - 1;
// Since we went back a year, we can't still be in a leap-year
if (earliestMonth == 2 && earliestDay == 29)
earliestDay = 28;
}
var earliest = Instant.FromUtc(earliestYear, earlistDateTimeToSupport.Month,
earlistDateTimeToSupport.Day, earlistDateTimeToSupport.Hour, earlistDateTimeToSupport.Minute);
else
{
// Going back to 1900, which wasn't a leap year, so we need to switch to Feb 20
if (earliestMonth == 2 && earliestDay == 29)
earliestDay = 28;
}
var earliest = Instant.FromUtc(earliestYear, earliestMonth, earliestDay,
earlistDateTimeToSupport.Hour, earlistDateTimeToSupport.Minute);

// Only include historical data if asked to do so. Otherwise,
// use only the most recent adjustment rules available.
Expand Down Expand Up @@ -371,4 +382,4 @@ public override int GetHashCode()
}
}
}
}
}

0 comments on commit 3f99776

Please sign in to comment.