Re: How to handle localtime() on old timestamps?



maruk2@xxxxxxxxxxx wrote:
I have some old data files with old timestamps, where
timestmap=time(NULL), some of them date back to the
year 1999.

localtime() seems to consider the presence of Daylight Saving
Time for the current day when it is actually called, but it does
not seem to consider the presence of Daylight Saving Time
for the old day.


For example, I run localtime on a timestamp from 3-22-1999
(Daylight Saving Time was not effective yet) today when Daylight
Saving Time is effective and localtime() returns hour:minute:second
one hour later as it should.


Does it mean that the only way around it is to keep transition
dates for Daylight Saving Time for all years and have my code
make the adjustments depending on the old day and the current
day? Is there any utility to do that or any better way?


Check the value of tm_isdst. If the value is positive then DST is
in effect, if it's zero then DST is not in effect. If that value
is negative then that information is not available. Unless you
get a negative value you should have correct DST information
provided that your system has up to date time zone information.
It may not be your case but time_t range and precision are
implementation defined and they can actually be different between
different versions of the same compiler.

Can you give me some timestamps, the tm values you get and the tm
values you expect?

--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
.



Relevant Pages

  • Re: How to handle localtime() on old timestamps?
    ... localtime() seems to consider the presence of Daylight Saving ... if it's zero then DST is not in effect. ...
    (comp.lang.c)
  • Get UTC time
    ... I want to store date and time values always in UTC in a DATE filed as a default value. ... The problem is that the OS has a timezone settings eg.: Asia/Peking and use always the actual local time (Daylight saving is handled correctly by the OS). ... I know that I can setup a dbtimezone for my database and update the localtime with that value, ...
    (comp.databases.oracle.server)
  • Re: Help with check time function
    ... using the UTC functions. ... The chage to/from DST normally occurs ... The clock for my mobile phone message system is in the same timezone ... Rather than daylight saving in summer, ...
    (comp.lang.javascript)
  • Re: Universal time in 4DOS?
    ... :: Test for TZ variable with DST rules defined in Mm.n.d format ... DST is used below to denote local daylight saving time ... ISDST requires a complete time zone environment variable ...
    (comp.os.msdos.4dos)
  • Re: Garmin 96C - Daylight saving time error!
    ... >>in March and October although DST commences on the first Sunday in April ... where the boundary between Eastern and Central timezones runs. ... Anyway it's your own fault if you can't set up Windows correctly for your ... Windows "knows" that daylight saving is not used. ...
    (sci.geo.satellite-nav)