Actions
Bug #1854
closedtimegm() works incorrect
Start date:
2011-12-04
Due date:
% Done:
0%
Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
External Bug:
Description
test code:
#include <stdio.h> #include <time.h> int main (void) { struct tm Tm; time_t time; strptime("Sun, 04 Dec 2011 13:09:43 GMT", "%a, %d %b %Y %H:%M:%S %Z", &Tm); time = timegm(&Tm); printf("Time1: %d\n", time); strptime("Sun, 04 Dec 2011 17:09:43 MSK", "%a, %d %b %Y %H:%M:%S %Z", &Tm); time = mktime(&Tm); printf("Time2: %d\n", time); }
Result:
# ./test Time1: 1323018583 Time2: 1323004183
As you can see timegm() returns seconds from the Epoch, with correction to local TZ, that is incorrect.
Result of same code, which compiled and started on Linux:
# ./test Time1: 1323004183 Time2: 1323004183
Updated by Vitaliy Gusev over 11 years ago
It is a strptime() issue. It does convert to locale's timezone if "GMT" specifier is in format.
Updated by Vitaliy Gusev over 11 years ago
As Garrett said "behavior is correct".
Actions