My issue is not around printf by around mktime(). I do not anderstand why mktime() change the .tm_isdst during the 26oct-27oct night. If you ntry this code you will find that the difference is 25H instead of 24H. If I force the .tm_isdst to 0 before mktime() call, a reverse ctime() call does gives the correct answer for "winter" date...
struct tm tmbidon;
time_t tbidon, myreference, tdiff;
tmbidon.tm_isdst = -1;
tmbidon.tm_year = 13 + 100; // ref 1900
tmbidon.tm_mon = 9; /* Months *since* january: 0-11 */
tmbidon.tm_mday = 27;
tmbidon.tm_hour = 9;
tmbidon.tm_min = 40;
tmbidon.tm_sec = 0;
myreference = mktime(&tmbidon);
tmbidon.tm_isdst = -1;
tmbidon.tm_mday = 26;
tbidon = mktime(&tmbidon);
tdiff = myreference-tbidon;
printf("diff %I64usec %fH\n", (u64)tdiff, ((float)tdiff)/3600);
printf("myreference %s", ctime(&myreference));
printf("tbidon %s", ctime(&tbidon));
tmbidon.tm_isdst = 0;
tmbidon.tm_year = 13 + 100; // ref 1900
tmbidon.tm_mon = 9; /* Months *since* january: 0-11 */
tmbidon.tm_mday = 27;
tmbidon.tm_hour = 9;
tmbidon.tm_min = 40;
tmbidon.tm_sec = 0;
myreference = mktime(&tmbidon);
tmbidon.tm_isdst = 0;
tmbidon.tm_mday = 26;
tbidon = mktime(&tmbidon);
tdiff = myreference-tbidon;
printf("diff %I64usec %fH\n", (u64)tdiff, ((float)tdiff)/3600);
printf("myreference %s", ctime(&myreference));
printf("tbidon %s", ctime(&tbidon));
Result:
diff 90000sec 25.000000H <=
myreference Sun Oct 27 09:40:00 2013
tbidon Sat Oct 26 09:40:00 2013
diff 86400sec 24.000000H
myreference Sun Oct 27 09:40:00 2013
tbidon Sat Oct 26 10:40:00 2013 <=
I agree that this not the appropriated forum and I will look for the coorect one.