rianjs / ical.net

ical.NET - an open source iCal library for .NET
MIT License
782 stars 230 forks source link

AsDateTimeOffset return wrong offset for America/mexico_city time zone #573

Open ShenChen93 opened 1 year ago

ShenChen93 commented 1 year ago

I get the nextOccurent which is of type IDateTime by following code:

var occurrences = calendar.GetOccurrences(searchStartTime, searchEndTime);
var nextOccurence = occurrences.First().Period.StartTime;

It has value "4/30/2023 9:00:00 PM america/mexico_city", but AsDateTimeOffset return wrong offset (It return -05:00, but it should be -06:00)

{4/30/2023 9:00:00 PM america/mexico_city}
    AsDateTimeOffset: {4/30/2023 9:00:00 PM -05:00}
    AsSystemLocal: {4/30/2023 9:00:00 PM}
    AsUtc: {5/1/2023 4:00:00 AM}
    AssociatedObject: Component: "VEVENT"
    Calendar: Component: "VCALENDAR"
    Date: {4/30/2023 12:00:00 AM}
    Day: 30
    DayOfWeek: Sunday
    DayOfYear: 120
    Encoding: null
    HasDate: true
    HasTime: true
    Hour: 21
    IsUtc: false
    Language: null
    Millisecond: 0
    Minute: 0
    Month: 4
    Parameters: {Ical.Net.Proxies.ParameterCollectionProxy}
    Second: 0
    Ticks: 638184852000000000
    TimeOfDay: {21:00:00}
    TimeZoneName: "america/mexico_city"
    TzId: "america/mexico_city"
    Value: {4/30/2023 9:00:00 PM}
    Year: 2023
    _AssociatedObject: Component: "VEVENT"
ShenChen93 commented 1 year ago

Not sure if it due to mexico_city no longer use DST starting from this year