diff src/c/urweb.c @ 1448:37599e85bba8

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
author Karn Kallio <kkallio@eka>
date Wed, 13 Apr 2011 00:04:41 -0430
parents 17393c5e2b90
children 0982f0242776
line wrap: on
line diff
--- a/src/c/urweb.c	Sat Apr 09 20:00:52 2011 -0400
+++ b/src/c/urweb.c	Wed Apr 13 00:04:41 2011 -0430
@@ -3763,23 +3763,13 @@
 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