Sign in to follow this  
Followers 0
ycomp

How to convert a foreign time to a local time?

5 posts in this topic

Hi,

here's what I'd like to do...

I'd like to be able to convert times from one time zone to another... but do it properly, observing all daylight savings rules.

I couldn't really find any way to do this easily so I decided it is ok to instead do this:

convert times from a foreign time zone to the system time zone

now I notice that there are 2 functions that can help me with this:

  • _Date_Time_SystemTimeToTzSpecificLocalTime ()
  • _Date_Time_TzSpecificLocalTimeToSystemTime ()

now the problem is that I can't figure out how to get a time zone's

$tagTIME_ZONE_INFORMATION structure

the only way I can figure this out is if I were to change the system time zone temporarily and then grab it...

that would solve all my problems

however it would introduce a new one, which is... that I don't want to be changing time zones at runtime. That seems to me to be too intrusive behaviour for a script and who knows? maybe it won't even work on vista for permissions reasons.

But luckily I only need a couple of predetermined time zones... e.g. London, Paris and a couple others

so I would like to then change the time zone temporarily to e.g. London, then grab the $tagTIME_ZONE_INFORMATION structure for it... and save it to a file somehow... e.g. London.tz

now my real script can access London.tz when it needs it.

So now my real script will load London.tz and create a $tagTIME_ZONE_INFORMATION structure for it to pass to Date_Time_TzSpecificLocalTimeToSystemTime () so that I can see what time 10:30 London is on my system.

The question is... how do I do this? First of all, is there a better way? If not, how do I serlialize/deserialize a $tagTIME_ZONE_INFORMATION structure to/from a file?

The reason I want to go to all this trouble to get things working properly is that the US change in time zone by a few weeks earlier now really messes things up.. I always want to calculate accurately... and also some other countries like Australia start DST at different times as well.

any help appreciated, thanks!

Share this post


Link to post
Share on other sites



why not just make vars that will tell you how much is a TZ different than your own

then just + and mod are your friends


----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Share this post


Link to post
Share on other sites

why not just make vars that will tell you how much is a TZ different than your own

then just + and mod are your friends

well I still need to know what days to adjust the time zones... based on the foreign time zone's dst change... and then I still need to know how to know what time it is in foreign time so that I know when their changeover occurs... since it may be the same day here and there, but the change may not have occured yet because it isn't the appropriate hour yet.

I was just thinking instead of trying to code things overly complicated, just to cheat and let windows do it for me. All I need to know is how to serialize in one way or another the time zone structure .

Share this post


Link to post
Share on other sites

well I still need to know what days to adjust the time zones... based on the foreign time zone's dst change... and then I still need to know how to know what time it is in foreign time so that I know when their changeover occurs... since it may be the same day here and there, but the change may not have occured yet because it isn't the appropriate hour yet.

I was just thinking instead of trying to code things overly complicated, just to cheat and let windows do it for me. All I need to know is how to serialize in one way or another the time zone structure .

I think I'll just have to make a bunch of dllstructset/getdata() calls... I was hoping there would be an easier solution. If anyone knows of one, let me know... thanks

Share this post


Link to post
Share on other sites

I guess you want to convert :

2009-1-21 12:38 CET

to

2009-1-21 ??:38 GMT

for example , right?

I need the same thing and will start working on the mater. But if you have anything ready ,please post.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0