M
Marina Levit
Hi,
I was getting odd results using ToLocalTime or ToUniversalTime on DateTime
objects - everything kept being off by 4 hours, not 5.
For example, timezone.CurrentTimeZone.GetUtcOffset(dt).TotalHours is always
equal to -4, not -5 (I'm on the east coast of the US). If I check my time
zone settings in windows, of course it says that I am -5 hours, which is
correct.
Incidentally, another issues is that if I call dt = DateTime.SpecifyKind(dt,
DateTimeKind.Local), the date coming back always has Kind= Unspecified,
never what I actually pass it. It just ignores the DateTimeKind entirely.
So, the GetUtcOffset result explains why everything is off by 4 and not 5 -
but the question is, why is that? It's like it is not taking into account
the whole daylight savings time business.
I was getting odd results using ToLocalTime or ToUniversalTime on DateTime
objects - everything kept being off by 4 hours, not 5.
For example, timezone.CurrentTimeZone.GetUtcOffset(dt).TotalHours is always
equal to -4, not -5 (I'm on the east coast of the US). If I check my time
zone settings in windows, of course it says that I am -5 hours, which is
correct.
Incidentally, another issues is that if I call dt = DateTime.SpecifyKind(dt,
DateTimeKind.Local), the date coming back always has Kind= Unspecified,
never what I actually pass it. It just ignores the DateTimeKind entirely.
So, the GetUtcOffset result explains why everything is off by 4 and not 5 -
but the question is, why is that? It's like it is not taking into account
the whole daylight savings time business.