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)
515 timedelta(microseconds=BadInt(1))
516 timedelta(hours=BadInt(1))
517 timedelta(weeks=BadInt(1))
518 timedelta(microseconds=BadLong(1))
519 timedelta(hours=BadLong(1))
520 timedelta(weeks=BadLong(1))
527 timedelta(microseconds=BadInt(1))
528 timedelta(hours=BadInt(1))
529 timedelta(weeks=BadInt(1))
530 timedelta(microseconds=BadLong(1))
531 timedelta(hours=BadLong(1))
532 timedelta(weeks=BadLong(1))
544 delta = timedelta(days=1, hours=2, minutes=3, seconds=4,
546 days = timedelta(delta.days)
547 self.assertEqual(days, timedelta(1))
559 days = timedelta(delta.days)
560 self.assertEqual(days, timedelta(-2))
656 b = a + timedelta(days=1)
668 b = a - timedelta(days=1)
728 day = timedelta(1)
729 week = timedelta(7)
770 for delta in [tiny, timedelta(1), timedelta(2)]:
828 delta=timedelta(seconds=0.5))
845 d = self.theclass(2003, 12, 29) + timedelta(i)
851 d = self.theclass(2009, 12, 28) + timedelta(i)
966 self.assertIsInstance(self.theclass.resolution, timedelta)
974 justasbig = timedelta(0, 0, n)
1302 us = timedelta(microseconds=1)
1394 millisec = timedelta(0, 0, 1000)
1395 hour = timedelta(0, 3600)
1396 day = timedelta(1)
1397 week = timedelta(7)
1579 tolerance = timedelta(seconds=1)
1690 def dst(self, dt): return timedelta(0)
1695 def utcoffset(self, dt): return timedelta(0)
1948 self.assertIsInstance(self.theclass.resolution, timedelta)
2045 return timedelta(minutes = dt and 42 or -42)
2053 expected = timedelta(minutes=(cls is time and -42 or 42))
2076 self.offset = timedelta(minutes=offset)
2115 def utcoffset(self, dt): return timedelta(minutes=-1439)
2116 def dst(self, dt): return timedelta(minutes=1439)
2119 self.assertEqual(t.utcoffset(), timedelta(minutes=-1439))
2120 self.assertEqual(t.dst(), timedelta(minutes=1439))
2135 def utcoffset(self, dt): return timedelta(hours=-24)
2136 def dst(self, dt): return timedelta(hours=24)
2143 def utcoffset(self, dt): return timedelta(seconds=61)
2144 def dst(self, dt): return timedelta(microseconds=-81)
2158 return timedelta(minutes=t.minute)
2161 return timedelta(minutes=59)
2224 self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
2225 self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
2226 self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
2236 self.assertEqual(t1.dst(), timedelta(minutes=1))
2237 self.assertEqual(t2.dst(), timedelta(minutes=-2))
2238 self.assertEqual(t3.dst(), timedelta(minutes=3))
2316 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
2350 zm200 = FixedOffset(timedelta(minutes=-200), "-200")
2400 self.offset = timedelta(minutes=22)
2402 self.offset += timedelta(minutes=1)
2408 self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
2409 self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
2520 return timedelta(minutes=1440) # out of bounds
2543 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
2570 self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
2571 self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
2572 self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
2625 self.assertEqual(now - now, timedelta(0))
2626 self.assertEqual(nowaware - nowaware, timedelta(0))
2629 delta = timedelta(weeks=1, minutes=12, microseconds=5678)
2665 timedelta(minutes=2*1439))
2676 self.assertEqual(another.utcoffset(), timedelta(minutes=42))
2688 weirdtz = FixedOffset(timedelta(hours=15, minutes=58), "weirdtz", 0)
2695 if abs(now - now2) < timedelta(seconds=30):
2714 self.assertEqual(another.utcoffset(), timedelta(minutes=42))
2732 utcoffset = timedelta(hours=-15, minutes=39) # arbitrary, but not zero
2766 dstvalue = timedelta(minutes=dstvalue)
2800 dstvalue = timedelta(minutes=dstvalue)
2813 self.uofs = timedelta(minutes=uofs)
2883 zm200 = FixedOffset(timedelta(minutes=-200), "-200")
2923 fm5h = FixedOffset(-timedelta(hours=5), "m300")
2940 self.assertEqual(got.utcoffset(), timedelta(hours=-5))
2959 return timedelta(minutes=t.minute)
2962 return timedelta(minutes=59)
2971 expected = timedelta(minutes=x.minute - y.minute)
2984 expected = timedelta(0)
2986 expected = timedelta(0)
2988 expected = timedelta(minutes=(11-59)-0)
2991 expected = timedelta(minutes=0-(11-59))
3008 self.offset = timedelta(minutes=22)
3010 self.offset += timedelta(minutes=1)
3016 self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
3017 self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
3055 dt += timedelta(days_to_go)
3058 ZERO = timedelta(0)
3059 HOUR = timedelta(hours=1)
3060 DAY = timedelta(days=1)
3072 self.stdoffset = timedelta(hours=hours)
3199 for delta in (timedelta(weeks=13),
3202 timedelta(minutes=1),
3203 timedelta(microseconds=1)):
3239 fourback = self.dston - timedelta(hours=4)
3270 first_std_hour = self.dstoff - timedelta(hours=2) # 23:MM
3328 expected -= timedelta(days=1)