Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Time zones

22 views
Skip to first unread message

Newsgroupie

unread,
Sep 14, 2008, 3:09:08 PM9/14/08
to
Hello fellow newsgroupies!

Is there a way of being able to find the time and DST in another time
zone from within an application other than by going into control panel
and effectively moving your entire PC to another time zone using 'date
and time'?

Also is there a way of getting a list of all the various time zones in
the world rather than just being able to get the name of the time zone
that your PC is currently set to (using the _get_tzname and
_get_timezone functions)?

Many thanks in advance,

'Newsgroupie'
England

Ashutosh Bhawasinka

unread,
Sep 15, 2008, 12:15:23 AM9/15/08
to
All the timezones are listed under this registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones

To get the time for another zone do something like this.
Let say t is the current local time.
Then get offset of the current time zone from the registry. Lets say
your current timezone is GMT + 5:30 (IST)

Now, you want time in US (Eastern time - US & Canada) which is GMT - 5:00

So, the time in US will be
t2 = t1 - (5:30 - (-5:00))

There might be some API also, but I am not aware of them. If there are
any, hope someone will reply...:)

Regards,
Ashutosh Bhawasinka

Serge Wautier

unread,
Sep 15, 2008, 2:34:17 AM9/15/08
to
Computing the local time in a given timezone is more complicated than that.
You also need to take DST into account, which is way more complex.

Fortunately, there is an API: SystemTimeToTzSpecificLocalTime()
Be aware though that this API has serious limitations if you want to use it
for 'old' timestamps, iow timestamps from previous DST periods (such as last
year or before).

HTH,

Serge.
http://www.apptranslator.com - Localization tool for your MFC applications

"Ashutosh Bhawasinka" <discu...@ashutosh.in> wrote in message
news:OOOT%23kuFJ...@TK2MSFTNGP03.phx.gbl...

Newsgroupie

unread,
Sep 15, 2008, 3:13:50 AM9/15/08
to
Thanks for all of your help so far, chaps!

Please keep it coming!

:-)

'Newsgroupie'
England

Ian Semmel

unread,
Sep 15, 2008, 2:46:48 PM9/15/08
to
I find it hard to get my head around timezones sometimes.

I have a system where the logical 'end of day' is 5am the next morning. Unfortunately, the customer is in a different timezone from
me and they have dst and I don't. Their dst time changes at 2am.

When testing, I don't want to change the time on my computer, as it messes up so many things, not least Visual Studio.

When testing, I tear my hair out adding 5 subtracting 2 (or is it 3) when dst starts and finishes.

Joseph M. Newcomer

unread,
Sep 17, 2008, 10:10:52 AM9/17/08
to
See also my Locale Explorer which shows code for many of the APIs related to time
maintenance.

But as already pointed out, there is no simple solution (I found out somewhere along the
line that one of the Australian states has DST only every-other-year because that's the
year of some important festival and they want extra time at night to celebrate. It may
have even been in this newsgroup someone pointed that out)
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

0 new messages