How to handle localtime() on old timestamps? Options

M

maruk2

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

I want my code to print the timestamps and each one to
include hour:minute:second as of the corresponding old day.
The only routine for this job seems to be
localtime(timestmap) - this is Windows Vista,
Visual Studio 2005 C++.

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.

localtime() returns struct tm with the field:
int tm_isdst; /* daylight savings time flag */
but it seems to be set on the basis of the current day
and not 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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top