[Zope3-checkins] SVN: Zope3/trunk/src/pytz/__init__.py Incorporate Stuart Bishop's feedback to pytz changes.

Gary Poster gary at zope.com
Tue Dec 20 09:48:14 EST 2005


Log message for revision 40903:
  Incorporate Stuart Bishop's feedback to pytz changes.
  
  

Changed:
  U   Zope3/trunk/src/pytz/__init__.py

-=-
Modified: Zope3/trunk/src/pytz/__init__.py
===================================================================
--- Zope3/trunk/src/pytz/__init__.py	2005-12-20 13:44:46 UTC (rev 40902)
+++ Zope3/trunk/src/pytz/__init__.py	2005-12-20 14:48:13 UTC (rev 40903)
@@ -219,6 +219,18 @@
     def __repr__(self):
         return 'pytz.FixedOffset(%d)' % self._minutes
 
+    def localize(self, dt, is_dst=False):
+        '''Convert naive time to local time'''
+        if dt.tzinfo is not None:
+            raise ValueError, 'Not naive datetime (tzinfo is already set)'
+        return dt.replace(tzinfo=self)
+
+    def normalize(self, dt, is_dst=False):
+        '''Correct the timezone information on the given datetime'''
+        if dt.tzinfo is None:
+            raise ValueError, 'Naive time - no tzinfo set'
+        return dt.replace(tzinfo=self)
+
 def FixedOffset(offset, _tzinfos = {}):
     """return a fixed-offset timezone based off a number of minutes.
     
@@ -283,7 +295,7 @@
 
     return info
 
-tzinfo.__safe_for_unpickling__ = True
+FixedOffset.__safe_for_unpickling__ = True
 
 def _test():
     import doctest, os, sys



More information about the Zope3-Checkins mailing list