Actions
Bug #2031
closedmktime and timegm are broken
Status:
Closed
Priority:
High
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Description
Both mktime and timegm are broken. They seem to always return -1 while any other
system with the same code returns the correct result.
This must have been broken for years, since no recent changes look suspicious.
Test case:
#include <stdio.h>
#include <time.h>
int main(void) {
struct tm tm;
time_t gm_time;
memset(&tm, 0, sizeof(struct tm));
tm.tm_sec = 20;
tm.tm_min = 1;
tm.tm_hour = 3;
tm.tm_mday = 15;
tm.tm_mon = 12;
tm.tm_year = 2010;
gm_time = mktime(&tm);
printf("Time is: %d\n", gm_time);
return 0;
}
Updated by alexh over 13 years ago
mea culpa, tm_year needs to be 2010 - 1900. closing this :)
Actions