fix todatetime implementation tls-sprint
authorsylvain.thenault@logilab.fr
Tue, 12 May 2009 18:14:46 +0200
branchtls-sprint
changeset 1751 59e9a4f5bfea
parent 1750 9df5e65c5f79
child 1752 4b0b912ff5b7
fix todatetime implementation
utils.py
--- a/utils.py	Tue May 12 17:39:50 2009 +0200
+++ b/utils.py	Tue May 12 18:14:46 2009 +0200
@@ -31,10 +31,11 @@
 
 def todatetime(somedate):
     """return a date from a date (leaving unchanged) or a datetime"""
-    if isinstance(somedate, date):
-        return datetime(somedate.year, somedate.month, somedate.day)
-    assert isinstance(somedate, datetime), repr(somedate)
-    return somedate
+    # take care, datetime is a subclass of date
+    if isinstance(somedate, datetime):
+        return somedate
+    assert isinstance(somedate, date), repr(somedate)
+    return datetime(somedate.year, somedate.month, somedate.day)
 
 ONEDAY = timedelta(days=1)
 ONEWEEK = timedelta(days=7)