todatetime impl., fix todate impl. tls-sprint
authorsylvain.thenault@logilab.fr
Thu, 30 Apr 2009 17:36:17 +0200
branchtls-sprint
changeset 1621 6260508f7d71
parent 1620 76680e515334
child 1622 1a1c494b88e2
todatetime impl., fix todate impl.
utils.py
--- a/utils.py	Thu Apr 30 17:35:43 2009 +0200
+++ b/utils.py	Thu Apr 30 17:36:17 2009 +0200
@@ -27,7 +27,14 @@
     if isinstance(somedate, datetime):
         return date(somedate.year, somedate.month, somedate.day)
     assert isinstance(somedate, date), repr(somedate)
-    return date
+    return somedate
+
+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
 
 ONEDAY = timedelta(days=1)