Reputation: 362
Date to convert : 12/10/2016 12:00:00 AM Time zone to convert : America/New_York
This is my function to return offset of the date (dt) I provide.
LocalDateTime fromLocal = LocalDateTime.FromDateTime(dt);
DateTimeZone fromZone = DateTimeZoneProviders.Tzdb[timeZone];
ZonedDateTime fromZoned = fromLocal.InZoneLeniently(fromZone);
return fromZoned.ToDateTimeOffset();
Result : 2016-12-10T00:00:00 America/New_York (-05)
When I google offset for America/New_York, I get -04 as offset.
Please help if anybody knows why this is happening.
Upvotes: 1
Views: 107
Reputation: 1500805
When I google offset for America/New_York, I get -04 as offset.
That would be true in the summer (and in particular it's the current offset at the time of your question), but not the winter (which would include 2016-12-10 - your "12/10/2016" is ambiguous in terms of whether it's in December or October).
America/New_York observes UTC-5 in winter, and UTC-4 in summer.
There's no bug here.
Upvotes: 3