🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages Started by Michael Thomsen Thu, 07 Aug 2008 09:42
Timezone problems
#47
Author: Michael Thomsen
Date: Thu, 07 Aug 2008 09:42
20 lines
1601 bytes
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/
Re: Timezone problems
#46
Author: Alan Bellingham
Date: Thu, 07 Aug 2008 10:03
16 lines
1442 bytes
"Michael Thomsen" <sorry@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
Re: Timezone problems
#48
Author: Alan Bellingham
Date: Thu, 07 Aug 2008 10:06
16 lines
1436 bytes
Alan Bellingham <alan@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
Re: Timezone problems
#49
Author: Michael Thomsen
Date: Thu, 07 Aug 2008 10:11
20 lines
1602 bytes
On Thu, 07 Aug 2008 12:03:08 +0200, Alan Bellingham <alan@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!

//michael

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Re: Timezone problems
#50
Author: Alan Bellingham
Date: Thu, 07 Aug 2008 10:32
12 lines
1391 bytes
"Michael Thomsen" <sorry@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
ACCU Conference 2009: Wed 22 - Sat 25 April 2009, Oxford
Re: Timezone problems
#51
Author: Remy Lebeau (TeamB)
Date: Thu, 07 Aug 2008 16:31
16 lines
1548 bytes
"Michael Thomsen" <sorry@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 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads