Exemplo n.º 1
0
 def testDeltaSeconds(self):
     'Should get the number of seconds represented by a timedelta.'
     td = datetime.timedelta(weeks=2, days=1, hours=1, minutes=3,
                             milliseconds=2000, microseconds=5000000)
     expected = 1299787
     actual = util.delta_seconds(td)
     self.assertEqual(expected, actual)
Exemplo n.º 2
0
 def usefulness(self):
     now = datetime.now()
     if not hasattr(self, 'date') or not self.date:
         self.date = now
     agesecs = util.delta_seconds(self.date - now)
     try:
         return float(self.hits) / agesecs
     except:
         return float(0)