Whether C# has bug about DST, if so, whether MS has provided fixabout it, and how?

K

ken

Anyone knows whether C# has bug about DST, if so, whether MS has
provided fix about it, and how? Thanks very much.

I set my timezone of my laptop to UTC +02:00 Jerusalem and check the
option - "automatically adjust clock for DST".

From http://www.timeanddate.com/worldclock/timezone.html?n=110&syear=2010,
we can see that at 2010-03-26 02:00, Jerusalem began to use DST and
changed timezone from UTC+2 to UTC+3.
I write a program to verify my guess: C# still uses UTC+2 for
Jerusalem until 04/01, and begin to use DST for Jerusalem (UTC+3) from
04/02.
System.DateTime givenDate = Convert.ToDateTime("03/24/2010 08:00");
givenDate = DateTime.SpecifyKind(givenDate, DateTimeKind.Local);
Console.WriteLine(givenDate.ToUniversalTime());

givenDate = Convert.ToDateTime("03/26/2010 08:00");
givenDate = DateTime.SpecifyKind(givenDate, DateTimeKind.Local);
Console.WriteLine(givenDate.ToUniversalTime());


givenDate = Convert.ToDateTime("04/01/2010 08:00");
givenDate = DateTime.SpecifyKind(givenDate, DateTimeKind.Local);
Console.WriteLine(givenDate.ToUniversalTime());

givenDate = Convert.ToDateTime("04/02/2010 08:00");
givenDate = DateTime.SpecifyKind(givenDate, DateTimeKind.Local);
Console.WriteLine(givenDate.ToUniversalTime());

3/24/2010 6:00:00 AM
3/26/2010 6:00:00 AM
4/1/2010 6:00:00 AM ===> C# still use UTC+2 for Jerusalem.
4/2/2010 5:00:00 AM ===> from 4/2 on, C# begin to use DST for
Jerusalem, changed to UTC+3

Anyone knows whether this is a C# bug, if so, how to fix it?
Thanks :)
 
A

Arne Vajhøj

Anyone knows whether C# has bug about DST, if so, whether MS has
provided fix about it, and how? Thanks very much.

I set my timezone of my laptop to UTC +02:00 Jerusalem and check the
option - "automatically adjust clock for DST".

From http://www.timeanddate.com/worldclock/timezone.html?n=110&syear=2010,
we can see that at 2010-03-26 02:00, Jerusalem began to use DST and
changed timezone from UTC+2 to UTC+3.

I am not sure that the term "changed timezone" is correct, but I
understand what you mean.
I write a program to verify my guess: C# still uses UTC+2 for
Jerusalem until 04/01, and begin to use DST for Jerusalem (UTC+3) from
04/02.
System.DateTime givenDate = Convert.ToDateTime("03/24/2010 08:00");
givenDate = DateTime.SpecifyKind(givenDate, DateTimeKind.Local);
Console.WriteLine(givenDate.ToUniversalTime());

givenDate = Convert.ToDateTime("03/26/2010 08:00");
givenDate = DateTime.SpecifyKind(givenDate, DateTimeKind.Local);
Console.WriteLine(givenDate.ToUniversalTime());


givenDate = Convert.ToDateTime("04/01/2010 08:00");
givenDate = DateTime.SpecifyKind(givenDate, DateTimeKind.Local);
Console.WriteLine(givenDate.ToUniversalTime());

givenDate = Convert.ToDateTime("04/02/2010 08:00");
givenDate = DateTime.SpecifyKind(givenDate, DateTimeKind.Local);
Console.WriteLine(givenDate.ToUniversalTime());

3/24/2010 6:00:00 AM
3/26/2010 6:00:00 AM
4/1/2010 6:00:00 AM ===> C# still use UTC+2 for Jerusalem.
4/2/2010 5:00:00 AM ===> from 4/2 on, C# begin to use DST for
Jerusalem, changed to UTC+3

Anyone knows whether this is a C# bug, if so, how to fix it?

It seems most likely that .NET get the DST info from Windows.

http://support.microsoft.com/kb/2443685

claims to have patch for all Windows versions that
should get Israel DST correct.

But Israel seems to be a tough case.

http://www.webexhibits.org/daylightsaving/g.html

<quote>
Israel always has Daylight Saving Time, but until 2005, it was decided
every year by the Ministry of Interior. There was no set rule for
Daylight Saving/Standard time changes, and there was long-running debate
between the majority of the secular public who wanted to extend daylight
saving as long as possible, and the religious public who wanted to end
it before Yom Kippur. One element was entrenched in law, however: that
there had to be at least 150 days of Daylight Saving Time annually.
</quote>

Yuck!

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top