diff options
author | 2011-04-12 23:04:41 -0530 | |
---|---|---|
committer | 2011-04-12 23:04:41 -0530 | |
commit | 5755d5b716190b46f966a80df85fb0cf63684327 (patch) | |
tree | 652167f312e989bbe1ad7c2c00a43dc4c7a17a32 | |
parent | 27e97143b6e20274484289ad61bfd9eb1922d50a (diff) |
Fix getting UTC time from formatted strings ( in uw_Basis_readUtc ).
Corrects 2 things:
- timezones with offsets not an integer number of hours
- double correcting for daylight savings time
-rw-r--r-- | src/c/urweb.c | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/src/c/urweb.c b/src/c/urweb.c index 0bc739fc..ab33a9c2 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -3763,23 +3763,13 @@ uw_Basis_bool uw_Basis_le_time(uw_context ctx, uw_Basis_time t1, uw_Basis_time t uw_Basis_time *uw_Basis_readUtc(uw_context ctx, uw_Basis_string s) { struct tm stm = {}; char *end = strchr(s, 0); - stm.tm_isdst = -1; if (strptime(s, TIME_FMT_PG, &stm) == end || strptime(s, TIME_FMT, &stm) == end) { uw_Basis_time *r = uw_malloc(ctx, sizeof(uw_Basis_time)); - tzset(); - stm.tm_hour -= timezone / (60 * 60); - - r->seconds = mktime(&stm); + r->seconds = timegm(&stm); r->microseconds = 0; - localtime_r(&r->seconds, &stm); - if (stm.tm_isdst == 1) { - ++stm.tm_hour; - r->seconds = mktime(&stm); - } - return r; } else |