Lines Matching refs:timedelta
14 from datetime import timedelta
46 offset = timedelta(minutes=offset)
48 dstoffset = timedelta(minutes=dstoffset)
95 self.assertEqual(fo.utcoffset(dt), timedelta(minutes=3))
97 self.assertEqual(fo.dst(dt), timedelta(minutes=42))
112 offset = timedelta(minutes=-300)
168 theclass = timedelta
172 td = timedelta
197 td = timedelta
242 a = timedelta(42)
268 td = timedelta(days, seconds, us)
274 td = timedelta(days=365)
277 td = timedelta(seconds=total_seconds)
282 td = timedelta(microseconds=ms)
288 t1 = timedelta(days=100,
294 t2 = timedelta(microseconds=1)
298 t1 = timedelta(days=100,
304 t2 = timedelta()
307 t1 += timedelta(weeks=7)
308 t2 += timedelta(days=7*7)
319 orig = timedelta(*args)
326 t1 = timedelta(2, 3, 4)
327 t2 = timedelta(2, 3, 4)
338 t2 = timedelta(*args) # this is larger than t1
370 td = timedelta
391 for td in (timedelta(days=999999999, hours=23, minutes=59,
393 timedelta(days=-999999999),
394 timedelta(days=1, seconds=2, microseconds=3)):
404 td2 = timedelta(td.days, td.seconds, td.microseconds)
408 self.assertIsInstance(timedelta.min, timedelta)
409 self.assertIsInstance(timedelta.max, timedelta)
410 self.assertIsInstance(timedelta.resolution, timedelta)
411 self.assertTrue(timedelta.max > timedelta.min)
412 self.assertEqual(timedelta.min, timedelta(-999999999))
413 self.assertEqual(timedelta.max, timedelta(999999999, 24*3600-1, 1e6-1))
414 self.assertEqual(timedelta.resolution, timedelta(0, 0, 1))
417 tiny = timedelta.resolution
419 td = timedelta.min + tiny
424 td = timedelta.max - tiny
429 self.assertRaises(OverflowError, lambda: -timedelta.max)
432 td = timedelta
453 td = timedelta(microseconds=-1)
458 self.assertTrue(timedelta(1))
459 self.assertTrue(timedelta(0, 1))
460 self.assertTrue(timedelta(0, 0, 1))
461 self.assertTrue(timedelta(microseconds=1))
462 self.assertFalse(timedelta(0))
466 class T(timedelta):
486 self.assertIs(type(t3), timedelta)
504 delta = timedelta(days=1, hours=2, minutes=3, seconds=4,
506 days = timedelta(delta.days)
507 self.assertEqual(days, timedelta(1))
519 days = timedelta(delta.days)
520 self.assertEqual(days, timedelta(-2))
616 b = a + timedelta(days=1)
628 b = a - timedelta(days=1)
688 day = timedelta(1)
689 week = timedelta(7)
730 for delta in [tiny, timedelta(1), timedelta(2)]:
788 delta=timedelta(seconds=0.5))
805 d = self.theclass(2003, 12, 29) + timedelta(i)
811 d = self.theclass(2009, 12, 28) + timedelta(i)
926 self.assertIsInstance(self.theclass.resolution, timedelta)
934 justasbig = timedelta(0, 0, n)
1262 us = timedelta(microseconds=1)
1354 millisec = timedelta(0, 0, 1000)
1355 hour = timedelta(0, 3600)
1356 day = timedelta(1)
1357 week = timedelta(7)
1539 tolerance = timedelta(seconds=1)
1650 def dst(self, dt): return timedelta(0)
1655 def utcoffset(self, dt): return timedelta(0)
1908 self.assertIsInstance(self.theclass.resolution, timedelta)
2005 return timedelta(minutes = dt and 42 or -42)
2013 expected = timedelta(minutes=(cls is time and -42 or 42))
2036 self.offset = timedelta(minutes=offset)
2075 def utcoffset(self, dt): return timedelta(minutes=-1439)
2076 def dst(self, dt): return timedelta(minutes=1439)
2079 self.assertEqual(t.utcoffset(), timedelta(minutes=-1439))
2080 self.assertEqual(t.dst(), timedelta(minutes=1439))
2095 def utcoffset(self, dt): return timedelta(hours=-24)
2096 def dst(self, dt): return timedelta(hours=24)
2103 def utcoffset(self, dt): return timedelta(seconds=61)
2104 def dst(self, dt): return timedelta(microseconds=-81)
2118 return timedelta(minutes=t.minute)
2121 return timedelta(minutes=59)
2184 self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
2185 self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
2186 self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
2196 self.assertEqual(t1.dst(), timedelta(minutes=1))
2197 self.assertEqual(t2.dst(), timedelta(minutes=-2))
2198 self.assertEqual(t3.dst(), timedelta(minutes=3))
2276 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
2310 zm200 = FixedOffset(timedelta(minutes=-200), "-200")
2360 self.offset = timedelta(minutes=22)
2362 self.offset += timedelta(minutes=1)
2368 self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
2369 self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
2480 return timedelta(minutes=1440) # out of bounds
2503 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
2530 self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
2531 self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
2532 self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
2585 self.assertEqual(now - now, timedelta(0))
2586 self.assertEqual(nowaware - nowaware, timedelta(0))
2589 delta = timedelta(weeks=1, minutes=12, microseconds=5678)
2625 timedelta(minutes=2*1439))
2636 self.assertEqual(another.utcoffset(), timedelta(minutes=42))
2648 weirdtz = FixedOffset(timedelta(hours=15, minutes=58), "weirdtz", 0)
2655 if abs(now - now2) < timedelta(seconds=30):
2674 self.assertEqual(another.utcoffset(), timedelta(minutes=42))
2692 utcoffset = timedelta(hours=-15, minutes=39) # arbitrary, but not zero
2726 dstvalue = timedelta(minutes=dstvalue)
2760 dstvalue = timedelta(minutes=dstvalue)
2773 self.uofs = timedelta(minutes=uofs)
2843 zm200 = FixedOffset(timedelta(minutes=-200), "-200")
2883 fm5h = FixedOffset(-timedelta(hours=5), "m300")
2900 self.assertEqual(got.utcoffset(), timedelta(hours=-5))
2919 return timedelta(minutes=t.minute)
2922 return timedelta(minutes=59)
2931 expected = timedelta(minutes=x.minute - y.minute)
2944 expected = timedelta(0)
2946 expected = timedelta(0)
2948 expected = timedelta(minutes=(11-59)-0)
2951 expected = timedelta(minutes=0-(11-59))
2968 self.offset = timedelta(minutes=22)
2970 self.offset += timedelta(minutes=1)
2976 self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
2977 self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
3015 dt += timedelta(days_to_go)
3018 ZERO = timedelta(0)
3019 HOUR = timedelta(hours=1)
3020 DAY = timedelta(days=1)
3032 self.stdoffset = timedelta(hours=hours)
3159 for delta in (timedelta(weeks=13),
3162 timedelta(minutes=1),
3163 timedelta(microseconds=1)):
3199 fourback = self.dston - timedelta(hours=4)
3230 first_std_hour = self.dstoff - timedelta(hours=2) # 23:MM
3288 expected -= timedelta(days=1)