c# - Wrong conversion of Moscow time to UTC -


the next code shows wrong local time if current location moscow:

datetime dt = new datetime(2010, 1, 1, 10, 0, 0, 0, datetimekind.utc); console.writeline(dt + " - " +  dt.tolocaltime());  dt = new datetime(2010, 7, 1, 10, 0, 0, 0, datetimekind.utc); console.writeline(dt + " - " + dt.tolocaltime()); 

output:

01.01.2010 10:00:00 - 01.01.2010 14:00:00 01.07.2010 10:00:00 - 01.07.2010 15:00:00 

it should 13:00 , 14:00. how fix it?

p.s. os - windows 7 enterprise.

this bug introduced windows historical timezone data. there hotfix available (this applies windows 7, server 2008 r2 , others, not xp).

hotfix: update 2011 calendar history in windows operating systems

as jmk said in comments, may want consider excellent library nodatime instead, particularly if distributing program users may not have hotfix.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -