utils.py
branchtls-sprint
changeset 1626 399ac5294471
parent 1625 744f0cc8758f
parent 1621 6260508f7d71
child 1697 5dae28906769
--- a/utils.py	Thu Apr 30 17:44:35 2009 +0200
+++ b/utils.py	Thu Apr 30 17:45:02 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)