views:

321

answers:

2

Hello;

I need help in writing a function which should take a datetime object and target timezone and it should return a datetime object after converting it to the target timezone - WHILE considering Day Light Saving of either target or current timezone.

Also, need a method to enumerate all available timezones.

I have been able to achieve this all in .NET 3.5, but my client's server is running .NET 2.0 and upgrading it is not possible.

Anyone who can help?

Good Day;

+1  A: 

Well, there's always System.TimeZone

http://msdn.microsoft.com/en-us/library/system.timezone.aspx

Robert Harvey
System.timezoneinfo is introduced in .NET 3.5.
effkay
+1  A: 

You'll need something like the Olson database to obtain such info, as .NET 2.0 knows only about the current time zone.

Look here: http://zoneinfo.codeplex.com/

Edit: Here's how to use it: CodeProject article

Tsvetomir Tsonev
Thanks... lemme check. I have found another article on CP, http://www.codeproject.com/KB/datetime/timezoneconversions.aspx, but this one does not work on Vista and Win2K8 I guess....
effkay
Well, that's a lot of P/Invoke going on here :) Imagine if you have to port this to Silverlight or Mono. Interesting approach nonetheless - might work on Vista too, but you have to test it.
Tsvetomir Tsonev
No, it is not working on VISTA, about the CodePlex library your specified, I can't seem to find the download link :| ... is it discarded?
effkay
No, but it's only available as source code. Shouldn't be a problem.
Tsvetomir Tsonev
Any luck with it?
Tsvetomir Tsonev