Skip to content

Commit

Permalink
fix incorrect localtime/gmtime
Browse files Browse the repository at this point in the history
System time return without offset, struct tm wYear start from 1900
so. localtime/gmtime alway return wrong date.
  • Loading branch information
darius-kim committed Apr 20, 2015
1 parent bad854b commit 1acd39a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ struct tm* localtime(const time_t* clock)
st_tm.tm_min = stLocal.wMinute;
st_tm.tm_hour = stLocal.wHour;
st_tm.tm_mday = stLocal.wDay;
st_tm.tm_mon = stLocal.wMonth;
st_tm.tm_year = stLocal.wYear;
st_tm.tm_mon = stLocal.wMonth - 1;
st_tm.tm_year = stLocal.wYear - 1900;
st_tm.tm_wday = stLocal.wDayOfWeek;
st_tm.tm_yday = dayOfYear(stLocal.wYear, stLocal.wMonth-1, stLocal.wDay);
if (tziResult == TIME_ZONE_ID_UNKNOWN)
Expand Down Expand Up @@ -601,8 +601,8 @@ struct tm* gmtime(const time_t* clock)
st_tm.tm_min = stUtc.wMinute;
st_tm.tm_hour = stUtc.wHour;
st_tm.tm_mday = stUtc.wDay;
st_tm.tm_mon = stUtc.wMonth;
st_tm.tm_year = stUtc.wYear;
st_tm.tm_mon = stUtc.wMonth - 1;
st_tm.tm_year = stUtc.wYear - 1900;
st_tm.tm_wday = stUtc.wDayOfWeek;
st_tm.tm_yday = dayOfYear(stUtc.wYear, stUtc.wMonth-1, stUtc.wDay);
st_tm.tm_isdst = 0;
Expand Down

0 comments on commit 1acd39a

Please sign in to comment.