Commits

Matthew Schinckel  committed 03c6915

Added more tests

  • Participants
  • Parent commits 1913215

Comments (0)

Files changed (2)

File timedelta/helpers.py

     else:
         return result
 
+def decimal_hours(timedelta):
+    """
+    Return a decimal value of the number of hours that this timedelta
+    object refers to.
+    """
+    return Decimal(timedelta.days*24) + Decimal(timedelta.seconds) / 3600

File timedelta/tests.py

         
         TODO: test with tzinfo (non-naive) datetimes/times.
         """
-    
+    
+    def test_decimal_hours(self):
+        """
+        >>> decimal_hours(datetime.timedelta(hours=5, minutes=30))
+        Decimal('5.5')
+        >>> decimal_hours(datetime.timedelta(hours=5))
+        Decimal('5')
+        >>> decimal_hours(datetime.timedelta(hours=9, minutes=20))
+        Decimal('9.333333333333333333333333333')
+        """