diff options
author | Guido van Rossum <guido@python.org> | 1993-06-23 09:30:50 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-06-23 09:30:50 (GMT) |
commit | 5cfa5dfe977854a090e70cb4f4353e2e6b46789e (patch) | |
tree | 2283617688b901adf8dbf07933f2dfe1f1c6c481 /Lib/tzparse.py | |
parent | 9b3bc715980b51ffbf535bcf159ba4be03938c19 (diff) | |
download | cpython-5cfa5dfe977854a090e70cb4f4353e2e6b46789e.zip cpython-5cfa5dfe977854a090e70cb4f4353e2e6b46789e.tar.gz cpython-5cfa5dfe977854a090e70cb4f4353e2e6b46789e.tar.bz2 |
* calendar.py: all libC functionality now moved to built-in time module
* imghdr.py: added jpeg recognition
* torgb.py: added jpeg conversion
* tzparse.py: use functions from time instead of calendar
* whatsound.py: add /ufs/guido/biin/sgi to $PATH when calling 'whatsound'
Diffstat (limited to 'Lib/tzparse.py')
-rw-r--r-- | Lib/tzparse.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/Lib/tzparse.py b/Lib/tzparse.py index 370d46b..26824ab 100644 --- a/Lib/tzparse.py +++ b/Lib/tzparse.py @@ -24,11 +24,11 @@ def tzparse(tzstr): [tzname, delta, dstname, daystart, hourstart, dayend, hourend] = subs return (tzname, delta, dstname, daystart, hourstart, dayend, hourend) -def tzlocaltime(time, params): - import calendar +def tzlocaltime(secs, params): + import time (tzname, delta, dstname, daystart, hourstart, dayend, hourend) = params - year, month, days, hours, mins, secs, yday, wday = \ - calendar.gmtime(time - delta*3600) + year, month, days, hours, mins, secs, yday, wday, isdst = \ + time.gmtime(secs - delta*3600) if (daystart, hourstart) <= (yday+1, hours) < (dayend, hourend): tzname = dstname hours = hours + 1 @@ -44,33 +44,39 @@ def tzset(): daylight = 1 tzname = tzparams[0], tzparams[2] -def isdst(time): - import calendar +def isdst(secs): + import time (tzname, delta, dstname, daystart, hourstart, dayend, hourend) = \ tzparams year, month, days, hours, mins, secs, yday, wday, isdst = \ - calendar.gmtime(time - delta*3600) + time.gmtime(secs - delta*3600) return (daystart, hourstart) <= (yday+1, hours) < (dayend, hourend) tzset() -def localtime(time): - return tzlocaltime(time, tzparams) +def localtime(secs): + return tzlocaltime(secs, tzparams) def test(): - from calendar import asctime, gmtime + from time import asctime, gmtime import time, sys now = time.time() x = localtime(now) - print 'now =', now, '=', asctime(x[:-1]), x[-1] + tm = x[:-1] + (0,) + print 'now =', now, '=', asctime(tm), x[-1] now = now - now % (24*3600) if sys.argv[1:]: now = now + eval(sys.argv[1]) x = gmtime(now) - print 'gmtime =', now, '=', asctime(x), 'yday =', x[-2] + tm = x[:-1] + (0,) + print 'gmtime =', now, '=', asctime(tm), 'yday =', x[-2] jan1 = now - x[-2]*24*3600 x = localtime(jan1) - print 'jan1 =', jan1, '=', asctime(x[:-1]), x[-1] + tm = x[:-1] + (0,) + print 'jan1 =', jan1, '=', asctime(tm), x[-1] for d in range(85, 95) + range(265, 275): t = jan1 + d*24*3600 x = localtime(t) - print 'd =', d, 't =', t, '=', asctime(x[:-1]), x[-1] + tm = x[:-1] + (0,) + print 'd =', d, 't =', t, '=', asctime(tm), x[-1] + +test() |