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



On May 11, 4:24 pm, Nelu <spamah...@xxxxxxxxx> wrote:
mar...@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?


isdst field is set to 1, apparently on the basis of *current" DST,
the old timestamp is not supposed to have DST.

localtime() should ignore the current DST, obviously it should
assume some timezone and the current timezone is fine.


.



Relevant Pages

  • Re: OT: history of daylight shifting time
    ... The idea of daylight saving time was first put into practice by the ... States and localities were free to observe daylight saving time ... In response to the 1973 energy crisis, ... agreed to a compromise bill that would extend DST by one month. ...
    (alt.guitar.amps)
  • Time Change DST 2007 question
    ... Below I have copied from IBM web page recommended "Apars" for the DST ... IY75214 DAYLIGHT SAVING TIME DEFAULT CHANGING IN 2007 ... IY34203 SMITTY CHTZ APPENDING 2 COMMAS AFTER TZ ... IY49871 SMITTY CHTZ_USER LIMITS THE EDITING OF TIMEZONE TO THREE ...
    (AIX-L)
  • Re: Off by an Hour
    ... there has been a major change in when DST will start in 2007 in the US. ... updated the OS to accommodate the change, but Entourage has not yet done so. ... Time error - New start/end dates for Daylight Saving Time ... this calendar is on an exchange server. ...
    (microsoft.public.mac.office.entourage)
  • Re: Adjust time dorked up on Win2000
    ... daylight saving time (DST) will change to comply with the Energy Policy ... DST dates for 2007 in the United States and Canada will ...
    (comp.sys.ibm.ps2.hardware)
  • updating java for DST changes
    ... new Daylight Saving Time rules in the US? ... On a testing or unstable system, the relevant data files are in the ... java doesn't trust the OS to get time zone and DST ...
    (Debian-User)