| View previous topic :: View next topic |
| Author |
Message |
Roger Guest
|
Posted: Sat Apr 07, 2007 8:10 am Post subject: Daylight Saving |
|
|
When using mktime() and storing the current time for later use I get a
problem with Daylight Saving.
The local time that I stored will be stored in Daylight Saving so if I
use that time in mktime and it is during Daylight Saving the hour will
be incremented.
What I do is:
tm tmTime
if (_daylight == 1) --tmTime.tm_hour; // decrement hour to compensate
for mktime
mktime(&tmTime); // if Daylight Saving mktime increments tmTime.tm_hour
This seems kludgy and I am wondering if there is another preferred
method for dealing with Daylight Saving?
Roger |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Apr 07, 2007 8:10 am Post subject: Re: Daylight Saving |
|
|
"Roger" <aretae (AT) magma (DOT) ca> wrote in message
news:46170b88$1 (AT) newsgroups (DOT) borland.com...
| Quote: | When using mktime() and storing the current time for later
use I get a problem with Daylight Saving.
|
Did you install Borland's patches for the new DST rules this year?
| Quote: | The local time that I stored will be stored in Daylight Saving so
if I use that time in mktime and it is during Daylight Saving the
hour will be incremented.
|
Have you considered storing the time in UTC/GMT format instead?
Gambit |
|
| Back to top |
|
 |
Roger Guest
|
Posted: Sat Apr 07, 2007 3:36 pm Post subject: Re: Daylight Saving |
|
|
| Quote: | Did you install Borland's patches for the new DST rules this year?
No, I assumed that this would just fix issues associated with crossing |
the DST boundary. At this time I don't care about that because I am not
interested in HoursBetween, difftime (other than for number of days),
etc when crossing any DST boundary, only for "normal business hours" of
the current date.
| Quote: | Have you considered storing the time in UTC/GMT format instead?
I don't think that will help. I guess instead of using if(_daylight == |
1) --tmDateTime.tm_hour a better way would be to take the current
datetime, store it in a structure, and use mktime to get time_t for use
in difftime. I just have to make sure I use mktime equally on both
arguments of difftime.
Thanks,
Roger |
|
| Back to top |
|
 |
Roger Guest
|
Posted: Sat Apr 07, 2007 4:33 pm Post subject: Re: Daylight Saving |
|
|
In my case, because I am using the current date, a better way is
probably just setting:
tmDateTime.tm_isdst = _daylight; before
mktime(&tmDateTime);
Roger |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Apr 07, 2007 11:08 pm Post subject: Re: Daylight Saving |
|
|
"Roger" <aretae (AT) magma (DOT) ca> wrote in message
news:46177431$1 (AT) newsgroups (DOT) borland.com...
| Quote: | No, I assumed that this would just fix issues associated
with crossing the DST boundary.
|
http://support.codegear.com/entry.jspa?externalID=6293&categoryID=37
Gambit |
|
| Back to top |
|
 |
|