viernes, noviembre 28, 2008

Windows and TimeZones

People from IT and DB guys have told me they can't rely on Windows when it comes to TimeZones and when time zone adjustments are necessary. I've seen systems re-implementing this feature again just to have have more control. At first this seemed unnecessary for me, but I just noticed today, talking with my sister in law that I had the wrong time of Argentina.

The main clock is Sydney in the image is Sydney.

I thought the cause was that Argentina was an additional clock and not my "main clock", so I change that and noticed that according to windows Buenos Aires start's the Daylight Savings beings on December. How hard is for windows to get this right?


According to the first page I found in Google ( Argentina moved to Daylight Saving and the time is 8:29 not 7:29.


How disappointed. Well, let's give it another try and manually update it.


Wait for a while


Doesn't work :(


Let's try another server


Same with all their servers. Failed. Why do they need so many servers only for time? If there were a valid reason, why would the user have to select a different one? Is it like Microsoft saying, "probably we will get it wrong, so we will give you more options just in case (which by the way might also fail)" or "probably you need to create your own time server in case you want to run an anarchy and don't want to go to daylight saving periods". This Internet Server's won't fix our Daylight Saving, they care about time not time zones, so they actually have an other purpose and could bring new problems for systems where seconds or milliseconds are important.

I remember that Microsoft distributed a patch for Windows and Windows Mobile to be able to adjust properly for the Daylight Saving in Sydney. Probably I need a patch for my recently configured Time Zone that went to summer time two months ago. Windows Update? Nothing

Well this isn't not that bad, Microsoft, has this Server product that works fantastic. But they still got it wrong (also in windows seven).


Now a typical discussion would go like this:

Customer: We need to adjust the {Enter Feature Heare} based on the time zones of our new markets.  
NET Guy: Microsoft is super cool. We can just rely on them for this time zone thingy and we don't care about it. When we do datetime comparisons it takes into account the TimeZone and when saving it or sending it over the wire that information is also considered and we can easily adjust it to UTC, transport or Local time.
IT Guy 1: That doesn't work. (Because .NET relys on the OS info)
IT Guy 2: All we need to do is keep patching the system for all our servers and client machines on time for all our different markets
IT Guy 1: That's a pain.
IT Guy 3: We better move the time manually and disable the auto adjust for daylight saving.
IT Guy 1: That's a pain in the !@$%!@(~. 
IT Guy 4: .NET Guy, could you do it for us?
NET Guy: I can't it's too complex. If MS didn't got it right it's because it's super dupper complex and we better not code it ourselves, it's going to be more painful. It's better to install that patches, that's why MS provides it.
IT Guy 4 (taking advantage of the super hero pride of the dev): Com'on you're better than Microsoft, you can do everything (sarcastically smiling)
Customer: Uses the puppy face look
NET Guy (all full in drunk in pride and self-steem): I am going to do it.

This is a code that should work on DotNet, but it doesn't.

// Buenos Aires at 19:45 (UTC -3 +1 For Daylight Saving) == UTC 21:45
var argentinianDate = new DateTime(2008, 11, 29, 19, 45, 0, DateTimeKind.Local);

// UTC 21:45 == 19:45 Buenos Aires
var utcDate = new DateTime(2008,11,29,21,45,0,DateTimeKind.Utc);



So if the OS gets it wrong, you will get it wrong also in .NET.

  1. There're other options hacks.

    According to this blog post. You can use this tool called "tzedit" to create a custom time zone and decide when you want to start your Daylight Savings. That way you and your family can start saving at a different time of the year, you will be probably late for work, but saving light.

  2. A blog from Microsoft even mentions as Option 1 to move your TZ to GMT-2.

  3. There other option is to install a patch, that isn't supported on Windows Vista and Server 2008 systems and it's only targeted to enterprise suers. What? By the way, this post was published one day before the daylight saving started.

No hay comentarios.: