Friday, December 24, 2010

Why Developers Always Need to use UTC

Assert.AreEqual(new DateTime(2010, 11, 07, 06, 0, 0, DateTimeKind.Utc).ToLocalTime(),
new DateTime(2010, 11, 07, 07, 0, 0, DateTimeKind.Utc).ToLocalTime());

Because when we fall back from Daylight Saving Time, the hour of 1am is repeated, making it ambiguous. Which is why the above test code passes in Central time, since 6am and 7am UTC are both 1am, one 1am CDT, the other 1am CST.

No comments: