codeblocks (en C sous windows) mktime
Bonjour,
J'ai un probleme de décalage d'1 heure qui se passe lorsque j'utilise la fonction mktime(). Ce décalage apparait dans la nuit du 26 au 27 octobre ????
Si je mets .tm_isdst a 0, le décalage apparait dans la fonction ctime().
Voici le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| 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)); |
Et le résultat:
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 <= ???:(
Est-ce que vous auriez une suggestion?
Merci
Mich