From 5755d5b716190b46f966a80df85fb0cf63684327 Mon Sep 17 00:00:00 2001 From: Karn Kallio Date: Tue, 12 Apr 2011 23:04:41 -0530 Subject: 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 --- src/c/urweb.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'src/c') 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 -- cgit v1.2.3