@@ -24,11 +24,11 @@ def tzparse(tzstr):
2424 [tzname , delta , dstname , daystart , hourstart , dayend , hourend ] = subs
2525 return (tzname , delta , dstname , daystart , hourstart , dayend , hourend )
2626
27- def tzlocaltime (time , params ):
28- import calendar
27+ def tzlocaltime (secs , params ):
28+ import time
2929 (tzname , delta , dstname , daystart , hourstart , dayend , hourend ) = params
30- year , month , days , hours , mins , secs , yday , wday = \
31- calendar .gmtime (time - delta * 3600 )
30+ year , month , days , hours , mins , secs , yday , wday , isdst = \
31+ time .gmtime (secs - delta * 3600 )
3232 if (daystart , hourstart ) <= (yday + 1 , hours ) < (dayend , hourend ):
3333 tzname = dstname
3434 hours = hours + 1
@@ -44,33 +44,39 @@ def tzset():
4444 daylight = 1
4545 tzname = tzparams [0 ], tzparams [2 ]
4646
47- def isdst (time ):
48- import calendar
47+ def isdst (secs ):
48+ import time
4949 (tzname , delta , dstname , daystart , hourstart , dayend , hourend ) = \
5050 tzparams
5151 year , month , days , hours , mins , secs , yday , wday , isdst = \
52- calendar .gmtime (time - delta * 3600 )
52+ time .gmtime (secs - delta * 3600 )
5353 return (daystart , hourstart ) <= (yday + 1 , hours ) < (dayend , hourend )
5454
5555tzset ()
5656
57- def localtime (time ):
58- return tzlocaltime (time , tzparams )
57+ def localtime (secs ):
58+ return tzlocaltime (secs , tzparams )
5959
6060def test ():
61- from calendar import asctime , gmtime
61+ from time import asctime , gmtime
6262 import time , sys
6363 now = time .time ()
6464 x = localtime (now )
65- print 'now =' , now , '=' , asctime (x [:- 1 ]), x [- 1 ]
65+ tm = x [:- 1 ] + (0 ,)
66+ print 'now =' , now , '=' , asctime (tm ), x [- 1 ]
6667 now = now - now % (24 * 3600 )
6768 if sys .argv [1 :]: now = now + eval (sys .argv [1 ])
6869 x = gmtime (now )
69- print 'gmtime =' , now , '=' , asctime (x ), 'yday =' , x [- 2 ]
70+ tm = x [:- 1 ] + (0 ,)
71+ print 'gmtime =' , now , '=' , asctime (tm ), 'yday =' , x [- 2 ]
7072 jan1 = now - x [- 2 ]* 24 * 3600
7173 x = localtime (jan1 )
72- print 'jan1 =' , jan1 , '=' , asctime (x [:- 1 ]), x [- 1 ]
74+ tm = x [:- 1 ] + (0 ,)
75+ print 'jan1 =' , jan1 , '=' , asctime (tm ), x [- 1 ]
7376 for d in range (85 , 95 ) + range (265 , 275 ):
7477 t = jan1 + d * 24 * 3600
7578 x = localtime (t )
76- print 'd =' , d , 't =' , t , '=' , asctime (x [:- 1 ]), x [- 1 ]
79+ tm = x [:- 1 ] + (0 ,)
80+ print 'd =' , d , 't =' , t , '=' , asctime (tm ), x [- 1 ]
81+
82+ test ()
0 commit comments