Skip to content

Commit

Permalink
always use mktimegm
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3570 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
bellard committed Nov 10, 2007
1 parent da0b0df commit 3c6b208
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,17 @@ int stristart(const char *str, const char *val, const char **ptr)
*ptr = p;
return 1;
}

time_t mktimegm(struct tm *tm)
{
time_t t;
int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday;
if (m < 3) {
m += 12;
y--;
}
t = 86400 * (d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 +
y / 400 - 719469);
t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
return t;
}
2 changes: 1 addition & 1 deletion vl.c
Original file line number Diff line number Diff line change
Expand Up @@ -8116,7 +8116,7 @@ int main(int argc, char **argv)
}
tm.tm_year -= 1900;
tm.tm_mon--;
rtc_start_date = timegm(&tm);
rtc_start_date = mktimegm(&tm);
if (rtc_start_date == -1) {
date_fail:
fprintf(stderr, "Invalid date format. Valid format are:\n"
Expand Down
1 change: 1 addition & 0 deletions vl.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ void pstrcpy(char *buf, int buf_size, const char *str);
char *pstrcat(char *buf, int buf_size, const char *s);
int strstart(const char *str, const char *val, const char **ptr);
int stristart(const char *str, const char *val, const char **ptr);
time_t mktimegm(struct tm *tm);

/* vl.c */
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
Expand Down

0 comments on commit 3c6b208

Please sign in to comment.