J
John
Howdy, everyone...
I've read some reference books, checked some old
code I wrote and have done some Googling to try and
get 'round this but haven't had any joy...
The attached code works Ok... and I understand that both
time() and localtime() do some magic with DST (daylight
saving time) when converting the longword time value. This
explains why the ctime() value and (most) values in the
tm structure are correct. However, I DON'T understand why
tm_isdst is zero, even though we're in DST right now in
Melbourne, .au.
I thought it might have something to do with locale functions...
but I've read a few on-line articles that state that no
MS-DOS/MS-Win compiler actually supports setlocale() in any
way as everything's hardwired.
This almost seems to be correct as when I run this program
after changing the system date to "June", the tm_isdst value
shows as '1', which would be correct for a USA-based time zone.
I've also tried setting a TZ environment variable (TZ=AEST10AEDST)
but that doesn't seem to make any difference. I generally don't
have a TZ variable defined.
A sample output follows:
Current Local Time: Thu Feb 24 21:47:21 2005
As a longword: 1109245641
BEFORE Local Time: 21:47:21
Local tm_isdst: 0
AFTER Local Time: 21:47:21
Local tm_isdst: 0
Any suggestions? I've tried building the program with Borland C++
Builder v4 (command line version) and Digital Mars C++ compiler.
The program behaves the same on Windows 98 SE OEM and WinXP SP1.
Thanks.
John
I've read some reference books, checked some old
code I wrote and have done some Googling to try and
get 'round this but haven't had any joy...
The attached code works Ok... and I understand that both
time() and localtime() do some magic with DST (daylight
saving time) when converting the longword time value. This
explains why the ctime() value and (most) values in the
tm structure are correct. However, I DON'T understand why
tm_isdst is zero, even though we're in DST right now in
Melbourne, .au.
I thought it might have something to do with locale functions...
but I've read a few on-line articles that state that no
MS-DOS/MS-Win compiler actually supports setlocale() in any
way as everything's hardwired.
This almost seems to be correct as when I run this program
after changing the system date to "June", the tm_isdst value
shows as '1', which would be correct for a USA-based time zone.
I've also tried setting a TZ environment variable (TZ=AEST10AEDST)
but that doesn't seem to make any difference. I generally don't
have a TZ variable defined.
A sample output follows:
Current Local Time: Thu Feb 24 21:47:21 2005
As a longword: 1109245641
BEFORE Local Time: 21:47:21
Local tm_isdst: 0
AFTER Local Time: 21:47:21
Local tm_isdst: 0
Any suggestions? I've tried building the program with Borland C++
Builder v4 (command line version) and Digital Mars C++ compiler.
The program behaves the same on Windows 98 SE OEM and WinXP SP1.
Thanks.
John