Hello all,
in following with my thread from last week about timezone conversions, I
decided to use UTC for time references. But there's still something wrong.
I have a time string, which I use to load a struct tm and then convert to a
time_t. First problem is that mktime uses local time. I thought, OK, I'll
just use it as if it was a UTC time, no difference.
And 2nd problem, if I call localtime to convert back, I'm off by one hour
and that doesn't make sense to me:
struct tm TM={0}, *TM2;
char *Pos="20120329-111359.dat"
sscanf (Pos, "%04d%02d%02d-%02d%02d%02d",
&TM.tm_year, &TM.tm_mon, &TM.tm_mday, &TM.tm_hour, &TM.tm_min, &TM.tm_sec);
TM.tm_year-=1900;
TM.tm_mon--;
Time=mktime(&TM); // tm_hour==11
TM2 = localtime (&Time); // tm_hour==12 - Doesn't make sense
Aren't mktime and localtime converse functions ?!?
--
Guillaume Dargaud
http://www.gdargaud.net/