Skip to content

Commit

Permalink
Fix for ical-org#378 - handle timezones which do not observe DST
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Fields committed May 3, 2018
1 parent 1968e2b commit cf088ec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net-core/Ical.Net/CalendarComponents/VTimeZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static VTimeZone FromDateTimeZone(string tzId, DateTime earlistDateTimeTo
// Only include historical data if asked to do so. Otherwise,
// use only the most recent adjustment rules available.
var intervals = vTimeZone._nodaZone.GetZoneIntervals(earliest, Instant.FromDateTimeOffset(DateTimeOffset.Now))
.Where(z => z.HasStart && z.Start != Instant.MinValue && z.HasEnd)
.Where(z => z.HasStart && z.Start != Instant.MinValue)
.ToList();

var matchingDaylightIntervals = new List<ZoneInterval>();
Expand Down Expand Up @@ -75,7 +75,7 @@ public static VTimeZone FromDateTimeZone(string tzId, DateTime earlistDateTimeTo
vTimeZone.AddChild(latestStandardTimeZoneInfo);

// check to see if there is no active, future daylight savings (ie, America/Phoenix)
if (latestStandardInterval != null && latestStandardInterval.End != Instant.MaxValue)
if (latestStandardInterval != null && (latestStandardInterval.HasEnd ? latestStandardInterval.End : Instant.MaxValue) != Instant.MaxValue)
{
//daylight
var daylightIntervals = intervals.Where(x => x.Savings.ToTimeSpan() != new TimeSpan(0)).ToList();
Expand Down Expand Up @@ -130,7 +130,7 @@ private static VTimeZoneInfo CreateTimeZoneInfo(List<ZoneInterval> matchedInterv
throw new InvalidOperationException("oldestInterval was not found");
}

var previousInterval = intervals.SingleOrDefault(x => x.End == oldestInterval.Start);
var previousInterval = intervals.SingleOrDefault(x => (x.HasEnd ? x.End : Instant.MaxValue) == oldestInterval.Start);

var delta = new TimeSpan(1, 0, 0);

Expand Down

0 comments on commit cf088ec

Please sign in to comment.