[pywin32-checkins] pywin32/win32/Lib win32timezone.py,1.3,1.4
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-12-30 08:10:28
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6469 Modified Files: win32timezone.py Log Message: Patch from Jason Coombs: Added __getinitargs__ so TimeZoneInfo objects can be pickled. Revised utcoffset() and dst() methods to return None when appropriate (as with datetime.time objects). Index: win32timezone.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32timezone.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32timezone.py 12 Apr 2005 06:14:01 -0000 1.3 --- win32timezone.py 30 Dec 2005 08:10:18 -0000 1.4 *************** *** 63,66 **** --- 63,71 ---- '(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London' + TimeZoneInfo now supports being pickled and comparison + >>> import pickle + >>> tz = win32timezone.TimeZoneInfo( 'China Standard Time' ) + >>> tz == pickle.loads( pickle.dumps( tz ) ) + True """ from __future__ import generators *************** *** 98,101 **** --- 103,109 ---- self.fixedStandardTime = fixedStandardTime + def __getinitargs__( self ): + return ( self.timeZoneName, ) + def _LoadInfoFromKey( self, key ): """Loads the information from an opened time zone registry key *************** *** 141,148 **** --- 149,160 ---- def utcoffset( self, dt ): "Calculates the utcoffset according to the datetime.tzinfo spec" + if dt is None: + return None return -( self.bias + self.dst( dt ) ) def dst( self, dt ): "Calculates the daylight savings offset according to the datetime.tzinfo spec" + if dt is None: + return None assert dt.tzinfo is self result = self.standardBiasOffset *************** *** 200,203 **** --- 212,218 ---- return result + def __cmp__( self, other ): + return cmp( self.__dict__, other.__dict__ ) + def _RegKeyEnumerator( key ): "Enumerates an open registry key as an iterable generator" |