>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
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/
>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
>> 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!
>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
> 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