summaryrefslogtreecommitdiff
path: root/sys/src/libc
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-08-11 02:19:02 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-08-11 02:19:02 +0200
commit4e3a8e41fb8b46f46f19f0dcdc170bc704c907e2 (patch)
tree3e3803d27efba4d13df14218cf709f0aaab754e7 /sys/src/libc
parent9fb29e09ea09ccdc4d99c72faf3b428daee83cc5 (diff)
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.
Diffstat (limited to 'sys/src/libc')
-rw-r--r--sys/src/libc/9sys/tm2sec.c14
1 files changed, 11 insertions, 3 deletions
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;
}