Commits

Matthew Schinckel committed 0b96dc4

Added week_containing function. Not really happy that it belongs here, though

  • Participants
  • Parent commits d2d1da0

Comments (0)

Files changed (1)

File timedelta/helpers.py

     Return a decimal value of the number of hours that this timedelta
     object refers to.
     """
-    return Decimal(timedelta.days*24) + Decimal(timedelta.seconds) / 3600
+    return Decimal(timedelta.days*24) + Decimal(timedelta.seconds) / 3600
+
+def week_containing(date):
+    if date.weekday():
+        date -= datetime.timedelta(date.weekday())
+    
+    return date, date + datetime.timedelta(6)