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.
This commit is contained in:
parent
9fb29e09ea
commit
4e3a8e41fb
1 changed files with 11 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue