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

Re: Timezone problems

6 views
Skip to first unread message

Alan Bellingham

unread,
Aug 7, 2008, 6:03:08 AM8/7/08
to
"Michael Thomsen" <so...@no.spam> wrote:

>Can anybody tell me what I'm doing wrong?

Is there any reason why you're not using GetSystemTime(), which is
documented as follows:

"The GetSystemTime function retrieves the current system date and time.
The system time is expressed in Coordinated Universal Time (UTC)."

(Otherwise, do check the PC's clock is actually set correctly.)

Alan Bellingham
--
Team Browns
ACCU Conference 2009: to be announced

Michael Thomsen

unread,
Aug 7, 2008, 5:42:00 AM8/7/08
to
Hello,

I would like to convert the current PC time into UTC. According to my
documentation the function GetTimeZoneInformation() should do what I
need, but either it doesn't work, or I do not understand how it works:

TTimeZoneInformation TimeZone;
GetTimeZoneInformation(&TimeZone);
TransmitPCtime(Now()+(double)(TimeZone.Bias+TimeZone.DaylightBias)/(60*24));

The above code works for most timezones, both with standard and daylight
saving time. However for certain timezones and standard/daylight saving
combinations (for instance Adelane, Australia) the result is not correct.

Can anybody tell me what I'm doing wrong?

//michael

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Alan Bellingham

unread,
Aug 7, 2008, 6:06:35 AM8/7/08
to
Alan Bellingham <al...@lspace.org> wrote:

>Is there any reason why you're not using GetSystemTime(), which is
>documented as follows:

I should point out that I was actually spelunking in this area recently,
trying to do the opposite - to get the local time and its offset for
display in a history file. I *was* using GetSystemTime(), when I
shouldn't have been.

(I was also in VC++, so Now() wasn't to hand.)

Alan Bellingham
--
Team Browns

ACCU Conference 2009: Wed 22 - Sat 25 April 2009, Oxford

Michael Thomsen

unread,
Aug 7, 2008, 6:11:24 AM8/7/08
to
On Thu, 07 Aug 2008 12:03:08 +0200, Alan Bellingham <al...@lspace.org>
wrote:

>> Can anybody tell me what I'm doing wrong?
>
> Is there any reason why you're not using GetSystemTime(), which is
> documented as follows:
>
> "The GetSystemTime function retrieves the current system date and time.
> The system time is expressed in Coordinated Universal Time (UTC)."

That can only be because I didn't happen to stumple upon it. I'll take
a look at it and see if it works better than my other "solution".

Thanks for your input!

Alan Bellingham

unread,
Aug 7, 2008, 6:32:25 AM8/7/08
to
"Michael Thomsen" <so...@no.spam> wrote:

>That can only be because I didn't happen to stumple upon it.

Ah, pretty much what I suspected. The first person to invent a sensible
context-sensitive help system for the Windows APIs will be an absolute
hero.

Alan Bellingham
--
Team Browns

Remy Lebeau (TeamB)

unread,
Aug 7, 2008, 12:31:08 PM8/7/08
to

"Michael Thomsen" <so...@no.spam> wrote in message
news:op.ufifwanvhrxo93@mtpc...

> I would like to convert the current PC time into UTC. According to
> my documentation the function GetTimeZoneInformation() should do
> what I need, but either it doesn't work, or I do not understand how it
> works:

You are not taking all of the TTimeZoneInformation values into account. The
DaylightBias value is only valid if GetTimeZoneInformation() returns
TIME_ZONE_ID_DAYLIGHT and the TTimeZoneInformation.DaylightDate.wMonth value
is not zero.


Gambit


0 new messages