diff options
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 370d46b912..26824ab929 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()  | 
