Commits

Georges Racinet  committed 5a6a3f7

#1: accepted optional time zone arg in now()

  • Participants
  • Parent commits 06dc844

Comments (0)

Files changed (4)

+
+Version 0.3.1 (2012-11-28)
+--------------------------
+
+ - #1: tested code using time zone optional arg of now() doesn't break
+   any more (no real time zone support, though)
 
 Version 0.3 (2012-11-23)
 ------------------------
 computational methods, actually return an object of the original
 ``datetime`` class. This works with python >= 2.6 only.
 
-First let's check that our class is a subclass of the orininal
+First let's check that our class is a subclass of the original
 one. If this fails, this test does not mean anything anymore::
 
   >>> datetime.datetime is datetime.original_datetime
   True
   >>> issubclass(datetime.original_datetime, datetime.datetime)
   True
+
+We'll need a ``tzinfo`` subclass from now on.
+
+  >>> from datetime import tzinfo
+  >>> class mytzinfo(tzinfo):
+  ...     def utcoffset(self, dt):
+  ...         return timedelta(hours=2)
+  ...     def dst(self, dt):
+  ...         return timedelta(0)
+
+When ``anybox.testing.datetime`` is not in use, the optional time zone
+argument of ``now`` can be passed without error
+
+  >>> n = datetime.datetime.now(mytzinfo())

File anybox/testing/datetime/mock_dt.py

     _current_now = None
 
     @classmethod
-    def now(cls):
+    def now(cls, *a):
         now = cls._current_now
         if now is not None:
+            # TODO timezone treatment
             return cls._current_now
-        return original_datetime.now()
+        return original_datetime.now(*a)
 
     @classmethod
     def set_now(cls, value):
 from setuptools import setup, find_packages
 
-version = '0.3'
+version = '0.3.1'
 
 setup(
     name = "anybox.testing.datetime",