Commit 3c6b20885dd6395882947e13901313a2fc291113

Authored by bellard
1 parent da0b0df8

always use mktimegm


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3570 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 3 changed files with 16 additions and 1 deletions
cutils.c
... ... @@ -81,3 +81,17 @@ int stristart(const char *str, const char *val, const char **ptr)
81 81 *ptr = p;
82 82 return 1;
83 83 }
  84 +
  85 +time_t mktimegm(struct tm *tm)
  86 +{
  87 + time_t t;
  88 + int y = tm->tm_year + 1900, m = tm->tm_mon + 1, d = tm->tm_mday;
  89 + if (m < 3) {
  90 + m += 12;
  91 + y--;
  92 + }
  93 + t = 86400 * (d + (153 * m - 457) / 5 + 365 * y + y / 4 - y / 100 +
  94 + y / 400 - 719469);
  95 + t += 3600 * tm->tm_hour + 60 * tm->tm_min + tm->tm_sec;
  96 + return t;
  97 +}
... ...
... ... @@ -8116,7 +8116,7 @@ int main(int argc, char **argv)
8116 8116 }
8117 8117 tm.tm_year -= 1900;
8118 8118 tm.tm_mon--;
8119   - rtc_start_date = timegm(&tm);
  8119 + rtc_start_date = mktimegm(&tm);
8120 8120 if (rtc_start_date == -1) {
8121 8121 date_fail:
8122 8122 fprintf(stderr, "Invalid date format. Valid format are:\n"
... ...
... ... @@ -123,6 +123,7 @@ void pstrcpy(char *buf, int buf_size, const char *str);
123 123 char *pstrcat(char *buf, int buf_size, const char *s);
124 124 int strstart(const char *str, const char *val, const char **ptr);
125 125 int stristart(const char *str, const char *val, const char **ptr);
  126 +time_t mktimegm(struct tm *tm);
126 127  
127 128 /* vl.c */
128 129 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
... ...