From 4e3a8e41fb8b46f46f19f0dcdc170bc704c907e2 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 11 Aug 2013 02:19:02 +0200 Subject: tm2sec: assume local timezone when Tm.zone[0] == 0 (fixes dossrv, zipfs timestamps) from the manual: Tm2sec converts a broken-down time to seconds since the start of the epoch. It ignores wday, and assumes the local time zone if zone is not GMT. so we can assume localtime if Tm.zone is not set to GMT. all code that wants no localtime conversion should set Tm.zone explicitely to GMT. (see previous commits) tm2sec() now does the reverse of localtime() when Tm.zone[0] == 0 which seems to be what the calling code (dossrv, zipfs) assumes. this also makes sense because theres no simple way todo it outside of libc as theres otherwise no access to the timezone structure with the daylight saving periods. --- sys/src/libc/9sys/tm2sec.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'sys/src') diff --git a/sys/src/libc/9sys/tm2sec.c b/sys/src/libc/9sys/tm2sec.c index 223d3f1d9..20bebd0c8 100644 --- a/sys/src/libc/9sys/tm2sec.c +++ b/sys/src/libc/9sys/tm2sec.c @@ -50,7 +50,7 @@ yrsize(int y) long tm2sec(Tm *tm) { - long secs; + long secs, *p; int i, yday, year, *d2m; if(strcmp(tm->zone, "GMT") != 0 && timezone.stname[0] == 0) @@ -95,8 +95,16 @@ tm2sec(Tm *tm) secs -= timezone.stdiff; else if(strcmp(tm->zone, timezone.dlname) == 0) secs -= timezone.dldiff; - if(secs < 0) - secs = 0; + else if(tm->zone[0] == 0){ + secs -= timezone.dldiff; + for(p = timezone.dlpairs; *p; p += 2) + if(secs >= p[0] && secs < p[1]) + break; + if(*p == 0){ + secs += timezone.dldiff; + secs -= timezone.stdiff; + } + } return secs; } -- cgit v1.2.3