tags:

views:

189

answers:

1

A program I wrote about four years ago, which gets the date and time as follows:

get_the_date_and_time(char *string) 
{
    struct tm *now;
    time_t lt;
    lt = time(NULL);
    now = localtime(&lt);
    sprintf(string,asctime(now));
}

It is returning the time an hour late since the switch to Daylight Saving Time.

By changing my system date to April 5, I get the right time.

We've done a work-around for the project involved; this is just a heads up.

I suspect Microsoft's Daylight Saving Time mods for the expansion of the Daylight Savings Time stretch is, if not broken, somewhat damaged.

+3  A: 

Sounds like your system isn't aware of the change to daylight savings in the US due to the 2005 Energy Policy Act (which made DST a month longer from 2007 onwards).

What version of Windows are you using, and have you kept it up to date with Windows Update?

EDIT: Also, is this linking statically or dynamically, and have you rebuilt since applying all patches etc? While I would hope it gets the information from the OS, it's possible that if you're linking statically some of it could be baked into your executable. (Ick.)

Jon Skeet
When he said "I suspect Microsoft's daylight savings mods", I took that as meaning that he'd already applied the patches.
Paul Tomblin
That's possible - it would really help if the question could be clarified. Even just knowing the OS would be a good start...
Jon Skeet