BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Understanding TTimeZoneInformation?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Sonnich
Guest





PostPosted: Tue Jan 17, 2006 5:51 pm    Post subject: Understanding TTimeZoneInformation? Reply with quote



Hi all!

I have a problem with understanding what TTimeZoneInformation returns?
Or more correctly to understand the result of this:

FillChar(TimeZoneInfo, SizeOf(TimeZoneInfo), #0);
GetTimeZoneInformation(TimeZoneInfo);

I am looking for the day, when time changes to/from daylight savings
time. Currently I use:

memo1.text :=
IntToStr(TimeZoneInfo.StandardDate.wYear)+'.'+
IntToStr(TimeZoneInfo.StandardDate.wMonth)+'.'+
IntToStr(TimeZoneInfo.StandardDate.wDay)+' '+
IntToStr(TimeZoneInfo.StandardDate.wHour)+':'+
IntToStr(TimeZoneInfo.StandardDate.wMinute);
memo1.lines.add(
IntToStr(TimeZoneInfo.DaylightDate.wYear)+'.'+
IntToStr(TimeZoneInfo.DaylightDate.wMonth)+'.'+
IntToStr(TimeZoneInfo.DaylightDate.wDay)+' '+
IntToStr(TimeZoneInfo.DaylightDate.wHour)+':'+
IntToStr(TimeZoneInfo.DaylightDate.wMinute));

And I get this surprising result:
0.10.5 4:0 (standard start)
0.3.5 3:0 (daylight start)

The first I get - March 5th., 2006 is a Sunday, and time changed at 2
o'clock (therefore it starts at 3 o'clock, which actually is 2).
But the October 5th is not a Sunday either this year (2006) nor last
(it is in 2003 and 2008). The change always happens on Sundays, and
always at 2 o'clock????

The Sunday thing is defenately incorrect. But 4 o'clocl? Usually
2:59:59 turns into 2:00:00 again (actually 3), which next time at
2:59:59 turns into 3:00:00 (which then actually is 4). A bit
complicated, but I can accept that.

Can anyone explain some of this?
Why is October 5th not a Sunday?

TIA
Sonnich

Back to top
alanglloyd@aol.com
Guest





PostPosted: Tue Jan 17, 2006 8:16 pm    Post subject: Re: Understanding TTimeZoneInformation? Reply with quote



MSDN says of DaylightDate ...

"DaylightDate
A SYSTEMTIME structure that contains a date and local time when the
transition from standard time to daylight saving time occurs on this
operating system. If this date is not specified, the wMonth member in
the SYSTEMTIME structure must be zero. If this date is specified, the
StandardDate value in the TIME_ZONE_INFORMATION structure must also be
specified.
To select the correct day in the month, set the wYear member to zero,
the wDayOfWeek member to an appropriate weekday, and the wDay member to
a value in the range 1 through 5. Using this notation, the first Sunday
in April can be specified, as can the last Thursday in October (5 is
equal to "the last")."

StandardTime is the same. So 5 is the last Sunday in the month
(whatever date that might be in the appropriate year).

So its actually 26 March 2006, not 5 March.

Alan Lloyd

Back to top
Dr John Stockton
Guest





PostPosted: Tue Jan 17, 2006 10:33 pm    Post subject: Re: Understanding TTimeZoneInformation? Reply with quote



JRS: In article <1137520282.394528.319470 (AT) g43g2000cwa (DOT) googlegroups.com>
, dated Tue, 17 Jan 2006 09:51:22 remote, seen in news:comp.lang.pascal.
delphi.misc, Sonnich <sonnich.jensen (AT) elektrobit (DOT) com> posted :
Quote:

And I get this surprising result:
0.10.5 4:0 (standard start)
0.3.5 3:0 (daylight start)

The first I get - March 5th., 2006 is a Sunday, and time changed at 2
o'clock (therefore it starts at 3 o'clock, which actually is 2).
But the October 5th is not a Sunday either this year (2006) nor last
(it is in 2003 and 2008). The change always happens on Sundays, and
always at 2 o'clock????

Well, you've not been smart enough to say where you *are*, so we can
only guess when your changes *should* be.

But, while 3 & 10 are the months, as year=0 then 5 is not the day-of-
month; instead, it means the fifth->last X-day of the month.

Clocks do not change on March 5 2006 in EU or US.

If your Delphi & Win32 Help are not enough - and Win32
TIME_ZONE_INFORMATION StandardDate para 3 covers it - <URL:http://www.me
rlyn.demon.co.uk/misctime.htm#TZ> links to the man page, or search the
Web for "The zero-based Julian day".

See also in TZ-CHECK.PAS, via <URL:http://www.merlyn.demon.co.uk/program
s/>

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

Back to top
Sonnich
Guest





PostPosted: Wed Jan 18, 2006 5:22 pm    Post subject: Re: Understanding TTimeZoneInformation? Reply with quote

Ok, thanks for the information.
As for being smart, my software might be used in different places of
the world, which makes it so, that I dont know where I am Smile
My system should be based on the (windows) systems, on which my
software run.

That leaves me with the TTimeZoneInformation as my only source.

I am now down to 2 issues:
a) as I know, changes happen and 2 o'clock - but I get 3 and 4.
For going to Daylight savings time, that is proper, as 2 does no exist,
we go straight to 3.
But for going the other one, I am confused... is that a windows thing?
Maybe, it is easier for windows, to wait until 4, then step back to
3.... should not mean anything, that from 2:59 it goes to 2:00. That
value should be 3 AFIAK. Didnt find much on the internet.

b) windows behaivour. I made a test today, turned the clock, to see
what would happen on March 26, from 1:50. It counted as it should (that
means it counted well into 2:20 which should be 3:20) ... not funny....

Does anyone know how windows does this, when I read the now:TDateTime?
I know, that windows can adjust this myself, but it didn't work as I
expected it too.

I'll do some more testing now. See how that is tomorrow.

/Sonnich

PS: found that the offset can be even GTM+12 3/4 ;-)

Back to top
alanglloyd@aol.com
Guest





PostPosted: Wed Jan 18, 2006 10:43 pm    Post subject: Re: Understanding TTimeZoneInformation? Reply with quote

Read my excerpt from MSDN carefully <g>

DaylightDate.wHour & .wMinute is when the system GOES TO daylight time.
Conversly StandardDate.wHour & .wMinute is when the system GOES TO
standard time.

ie for your figures the system GOES TO daylight time at 3.00 (local
time flips from 3.00 to 4.00), and GOES TO standard time at 4.00 (local
time flips from 4.00 to 3.00).

For actual changing maybe windows changes in accordance with time zones
only at boot-up, not while running.

Alan Lloyd

Back to top
Hans-Peter Diettrich
Guest





PostPosted: Thu Jan 19, 2006 5:13 am    Post subject: Re: Understanding TTimeZoneInformation? Reply with quote

[email]alanglloyd (AT) aol (DOT) com[/email] schrieb:

Quote:
For actual changing maybe windows changes in accordance with time zones
only at boot-up, not while running.

AFAIR the daylight saving adjustments occur when Windows is running -
otherwise the local time would be wrong until the next reboot.

I also found multiple updates, when different Windows systems are used
on the same machine, resulting in a time shift of N hours after each
system has adjusted the time Sad
(Consequently I disabled automatic adjustment in all my Windows systems)

It would be much better to leave the hardware clock at UTC, and to apply
time shifts only in requests of the local time.

Perhaps it would "save" more time and money, when the daylight shift
would be dropped at all, but that's another (political) story :-(

DoDi

Back to top
Dr John Stockton
Guest





PostPosted: Thu Jan 19, 2006 4:32 pm    Post subject: Re: Understanding TTimeZoneInformation? Reply with quote

JRS: In article <1137624231.888819.157420 (AT) g43g2000cwa (DOT) googlegroups.com>
, dated Wed, 18 Jan 2006 14:43:51 remote, seen in news:comp.lang.pascal.
delphi.misc, [email]alanglloyd (AT) aol (DOT) com[/email] <alanglloyd (AT) aol (DOT) com> posted :
Quote:
Read my excerpt from MSDN carefully <g

DaylightDate.wHour & .wMinute is when the system GOES TO daylight time.
Conversly StandardDate.wHour & .wMinute is when the system GOES TO
standard time.

ie for your figures the system GOES TO daylight time at 3.00 (local
time flips from 3.00 to 4.00), and GOES TO standard time at 4.00 (local
time flips from 4.00 to 3.00).

For actual changing maybe windows changes in accordance with time zones
only at boot-up, not while running.

Note : IIRC, the times are given in current (previous) clock time, so
that the USA always changes at 2 but we change at 2 in autumn and 1 in
spring. Giving the changes in Standard (Winter) time would be more
logical. Giving them in UTC, or even GMT, would be even better.

IIRC, an old Windows release put the clock back, on the relevant date,
at (US) 3 a.m.; an hour later, at 3 a.m., it put the clock back; an hour
later, ... ... ... .

ISTM possible, for systems where the basic timekeeping (as in DOS) is in
local time, that they then simply arranged not to put the clock back
until more than an hour, or at least a day, had passed.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

Back to top
Sonnich
Guest





PostPosted: Fri Jan 20, 2006 8:26 am    Post subject: Re: Understanding TTimeZoneInformation? Reply with quote

As I found after studuing this, it _should_ be so, that all hours are
present. That should be why the change to Standard time is one hour
later than the change to DST.
Wehn going to DST one will miss one hour, which then will repeat itself
when going back.

But it seems that in some places in the US this does not apply.

Back to top
Dr John Stockton
Guest





PostPosted: Fri Jan 20, 2006 10:38 pm    Post subject: Re: Understanding TTimeZoneInformation? Reply with quote

JRS: In article <1137745578.370766.311610 (AT) z14g2000cwz (DOT) googlegroups.com>
, dated Fri, 20 Jan 2006 00:26:18 remote, seen in news:comp.lang.pascal.
delphi.misc, Sonnich <sonnich.jensen (AT) elektrobit (DOT) com> posted :
Quote:
As I found after studuing this, it _should_ be so, that all hours are
present. That should be why the change to Standard time is one hour
later than the change to DST.
Wehn going to DST one will miss one hour, which then will repeat itself
when going back.

But it seems that in some places in the US this does not apply.


If you find that, when you start a News reply, Google does not provide
the previous article in quoted form, note what Keith Thompson wrote in
comp.lang.c, message ID <lnwtuhfy7d.fsf (AT) nuthaus (DOT) mib.org> :-
If you want to post a followup via groups.google.com, don't use
the "Reply" link at the bottom of the article. Click on "show
options" at the top of the article, then click on the "Reply" at
the bottom of the article headers.

Since that is what the experts in this newsgroup will prefer to read, it
will be to your advantage to comply.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.