Lines Matching refs:timedelta
27 from datetime import timedelta
119 offset = timedelta(minutes=offset)
121 dstoffset = timedelta(minutes=dstoffset)
182 self.assertEqual(fo.utcoffset(dt), timedelta(minutes=3))
184 self.assertEqual(fo.dst(dt), timedelta(minutes=42))
199 offset = timedelta(minutes=-300)
219 DSTDIFF = DSTOFFSET = timedelta(hours=1)
244 self.ACDT = timezone(timedelta(hours=9.5), 'ACDT')
245 self.EST = timezone(-timedelta(hours=5), 'EST')
262 limit = timedelta(hours=23, minutes=59)
268 self.assertIs(timezone.utc, timezone(timedelta(0)))
269 self.assertIsNot(timezone.utc, timezone(timedelta(0), 'UTC'))
270 self.assertEqual(timezone.utc, timezone(timedelta(0), 'UTC'))
271 for subminute in [timedelta(microseconds=1), timedelta(seconds=1)]:
273 self.assertNotEqual(tz.utcoffset(None) % timedelta(minutes=1), 0)
275 for invalid in [timedelta(1, 1), timedelta(1)]:
311 self.assertEqual('UTC-00:01', timezone(timedelta(minutes=-1)).tzname(None))
317 self.assertEqual('UTC+01:06:40', timezone(timedelta(0, 4000)).tzname(None))
319 timezone(-timedelta(0, 4000)).tzname(None))
321 timezone(timedelta(0, 4000, 1)).tzname(None))
323 timezone(-timedelta(0, 4000, 1)).tzname(None))
401 timedelta(hours=23, minutes=59),
402 timedelta(hours=23, minutes=59, seconds=59),
403 timedelta(hours=23, minutes=59, seconds=59, microseconds=999999),
413 timedelta(hours=24),
414 timedelta(hours=24, microseconds=1),
427 self.assertNotEqual(timezone(timedelta(hours=1)), tzinfo())
486 theclass = timedelta
490 td = timedelta
515 td = timedelta
597 a = timedelta(42)
617 a = timedelta(42)
623 td = timedelta(days, seconds, us)
629 td = timedelta(days=365)
632 td = timedelta(seconds=total_seconds)
637 td = timedelta(microseconds=ms)
638 self.assertEqual(td.total_seconds(), td / timedelta(seconds=1))
641 t1 = timedelta(days=100,
647 t2 = timedelta(microseconds=1)
651 t1 = timedelta(days=100,
657 t2 = timedelta()
660 t1 += timedelta(weeks=7)
661 t2 += timedelta(days=7*7)
672 orig = timedelta(*args)
679 t1 = timedelta(2, 3, 4)
680 t2 = timedelta(2, 3, 4)
689 t2 = timedelta(*args) # this is larger than t1
719 td = timedelta
759 for td in (timedelta(days=999999999, hours=23, minutes=59,
761 timedelta(days=-999999999),
762 timedelta(days=-999999999, seconds=1),
763 timedelta(days=1, seconds=2, microseconds=3)):
773 td2 = timedelta(td.days, td.seconds, td.microseconds)
777 self.assertIsInstance(timedelta.min, timedelta)
778 self.assertIsInstance(timedelta.max, timedelta)
779 self.assertIsInstance(timedelta.resolution, timedelta)
780 self.assertTrue(timedelta.max > timedelta.min)
781 self.assertEqual(timedelta.min, timedelta(-999999999))
782 self.assertEqual(timedelta.max, timedelta(999999999, 24*3600-1, 1e6-1))
783 self.assertEqual(timedelta.resolution, timedelta(0, 0, 1))
786 tiny = timedelta.resolution
788 td = timedelta.min + tiny
793 td = timedelta.max - tiny
798 self.assertRaises(OverflowError, lambda: -timedelta.max)
800 day = timedelta(1)
809 day = timedelta(1)
814 td = timedelta
847 td = timedelta(microseconds=-1)
852 self.assertTrue(timedelta(1))
853 self.assertTrue(timedelta(0, 1))
854 self.assertTrue(timedelta(0, 0, 1))
855 self.assertTrue(timedelta(microseconds=1))
856 self.assertFalse(timedelta(0))
860 class T(timedelta):
880 self.assertIs(type(t3), timedelta)
894 td = timedelta(days=1)
913 td = timedelta(days=1, minutes=30)
928 t = timedelta(hours=1, minutes=24, seconds=19)
929 second = timedelta(seconds=1)
933 t = timedelta(minutes=2, seconds=30)
934 minute = timedelta(minutes=1)
938 zerotd = timedelta(0)
947 t = timedelta(minutes=2, seconds=30)
948 minute = timedelta(minutes=1)
950 self.assertEqual(r, timedelta(seconds=30))
952 t = timedelta(minutes=-2, seconds=30)
954 self.assertEqual(r, timedelta(seconds=30))
956 zerotd = timedelta(0)
962 t = timedelta(minutes=2, seconds=30)
963 minute = timedelta(minutes=1)
966 self.assertEqual(r, timedelta(seconds=30))
968 t = timedelta(minutes=-2, seconds=30)
971 self.assertEqual(r, timedelta(seconds=30))
973 zerotd = timedelta(0)
988 timedelta() / get_bad_float(1 << 1000)
990 timedelta() * get_bad_float(1 << 1000)
994 timedelta() / get_bad_float(bad_ratio)
996 timedelta() * get_bad_float(bad_ratio)
1025 timedelta(microseconds=BadInt(1))
1029 timedelta(hours=BadInt(1))
1033 timedelta(weeks=BadInt(1))
1037 timedelta(1) * BadInt(1)
1041 BadInt(1) * timedelta(1)
1045 timedelta(1) // BadInt(1)
1059 delta = timedelta(days=1, hours=2, minutes=3, seconds=4,
1061 days = timedelta(delta.days)
1062 self.assertEqual(days, timedelta(1))
1074 days = timedelta(delta.days)
1075 self.assertEqual(days, timedelta(-2))
1171 b = a + timedelta(days=1)
1183 b = a - timedelta(days=1)
1244 day = timedelta(1)
1245 week = timedelta(7)
1287 for delta in [tiny, timedelta(1), timedelta(2)]:
1345 delta=timedelta(seconds=0.5))
1373 new_date = base_date + timedelta(i)
1535 self.assertIsInstance(self.theclass.resolution, timedelta)
1543 justasbig = timedelta(0, 0, n)
2035 tz = FixedOffset(timedelta(seconds=16), 'XXX')
2041 ('05:00', timedelta(hours=5)),
2042 ('02:00', timedelta(hours=2)),
2043 ('06:27', timedelta(hours=6, minutes=27)),
2044 ('12:32:30', timedelta(hours=12, minutes=32, seconds=30)),
2045 ('02:04:09.123456', timedelta(hours=2, minutes=4, seconds=9, microseconds=123456))
2051 ('+00:00', timezone(timedelta(0))),
2127 us = timedelta(microseconds=1)
2227 millisec = timedelta(0, 0, 1000)
2228 hour = timedelta(0, 3600)
2229 day = timedelta(1)
2230 week = timedelta(7)
2402 t0 - timedelta(hours=1))
2404 t1 + timedelta(hours=1))
2426 tzinfo=timezone(timedelta(hours=-5), 'EST'))
2546 tolerance = timedelta(seconds=1)
2583 -timedelta(minutes=2, seconds=1, microseconds=3)
2597 self.assertEqual(dt.utcoffset(), timedelta(seconds=tzseconds))
2675 tz = timezone(-timedelta(hours=2, seconds=s, microseconds=us))
2753 dt_utc = dt.replace(tzinfo=timezone(timedelta(hours=-4), 'EDT'))
2757 dt_f = dt.replace(tzinfo=f) + timedelta(hours=4, minutes=44)
2763 def dst(self, dt): return timedelta(0)
2769 def utcoffset(self, dt): return timedelta(0)
2871 ('now_fixed', 'now', {'tz': timezone(timedelta(hours=-5), "EST")}),
2901 timezone(timedelta(hours=-5)),
2902 timezone(timedelta(hours=2))]
2921 timedelta(hours=5), timedelta(hours=2),
2922 timedelta(hours=6, minutes=27),
2923 timedelta(hours=12, minutes=32, seconds=30),
2924 timedelta(hours=2, minutes=4, seconds=9, microseconds=123456)
2930 timezone(timedelta(hours=0))]
2976 timezone(timedelta(hours=-5)),
2977 timezone(timedelta(hours=2)),
2978 timezone(timedelta(hours=6, minutes=27))]
3053 tzinfo=timezone(timedelta(hours=10, minutes=45)))
3248 ('05:00', timedelta(hours=5)),
3249 ('02:00', timedelta(hours=2)),
3250 ('06:27', timedelta(hours=6, minutes=27)),
3251 ('12:32:30', timedelta(hours=12, minutes=32, seconds=30)),
3252 ('02:04:09.123456', timedelta(hours=2, minutes=4, seconds=9, microseconds=123456))
3258 ('+00:00', timezone(timedelta(0))),
3343 self.assertIsInstance(self.theclass.resolution, timedelta)
3475 return timedelta(minutes = dt and 42 or -42)
3483 expected = timedelta(minutes=(cls is time and -42 or 42))
3506 self.offset = timedelta(minutes=offset)
3545 def utcoffset(self, dt): return timedelta(minutes=-1439)
3546 def dst(self, dt): return timedelta(minutes=1439)
3549 self.assertEqual(t.utcoffset(), timedelta(minutes=-1439))
3550 self.assertEqual(t.dst(), timedelta(minutes=1439))
3565 def utcoffset(self, dt): return timedelta(hours=-24)
3566 def dst(self, dt): return timedelta(hours=24)
3573 def utcoffset(self, dt): return timedelta(microseconds=61)
3574 def dst(self, dt): return timedelta(microseconds=-81)
3576 self.assertEqual(t.utcoffset(), timedelta(microseconds=61))
3577 self.assertEqual(t.dst(), timedelta(microseconds=-81))
3588 return timedelta(minutes=t.minute)
3591 return timedelta(minutes=59)
3655 self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
3656 self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
3657 self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
3667 self.assertEqual(t1.dst(), timedelta(minutes=1))
3668 self.assertEqual(t2.dst(), timedelta(minutes=-2))
3669 self.assertEqual(t3.dst(), timedelta(minutes=3))
3754 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
3789 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
3811 zm200 = FixedOffset(timedelta(minutes=-200), "-200")
3861 self.offset = timedelta(minutes=22)
3863 self.offset += timedelta(minutes=1)
3869 self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
3870 self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
3891 timezone(timedelta(hours=2)),
3892 timezone(timedelta(hours=6, minutes=27))]
3907 timedelta(hours=5), timedelta(hours=2),
3908 timedelta(hours=6, minutes=27),
3909 timedelta(hours=12, minutes=32, seconds=30),
3910 timedelta(hours=2, minutes=4, seconds=9, microseconds=123456)
3916 timezone(timedelta(hours=0))]
3935 timezone(timedelta(hours=-5)),
3936 timezone(timedelta(hours=2)),
3937 timezone(timedelta(hours=6, minutes=27))]
4112 return timedelta(minutes=1440) # out of bounds
4136 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
4174 self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
4201 self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
4202 self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
4203 self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
4254 self.assertEqual(now - now, timedelta(0))
4255 self.assertEqual(nowaware - nowaware, timedelta(0))
4258 delta = timedelta(weeks=1, minutes=12, microseconds=5678)
4294 timedelta(minutes=2*1439))
4310 self.assertEqual(another.utcoffset(), timedelta(minutes=42))
4323 for weirdtz in [FixedOffset(timedelta(hours=15, minutes=58), "weirdtz", 0),
4324 timezone(timedelta(hours=15, minutes=58), "weirdtz"),]:
4330 if abs(now - now2) < timedelta(seconds=30):
4349 self.assertEqual(another.utcoffset(), timedelta(minutes=42))
4367 utcoffset = timedelta(hours=-15, minutes=39) # arbitrary, but not zero
4401 dstvalue = timedelta(minutes=dstvalue)
4435 dstvalue = timedelta(minutes=dstvalue)
4448 self.uofs = timedelta(minutes=uofs)
4535 zm200 = FixedOffset(timedelta(minutes=-200), "-200")
4575 fm5h = FixedOffset(-timedelta(hours=5), "m300")
4590 self.assertEqual(got.utcoffset(), timedelta(hours=-5))
4636 return timedelta(minutes=t.minute)
4639 return timedelta(minutes=59)
4648 expected = timedelta(minutes=x.minute - y.minute)
4661 expected = timedelta(0)
4663 expected = timedelta(0)
4665 expected = timedelta(minutes=(11-59)-0)
4668 expected = timedelta(minutes=0-(11-59))
4685 self.offset = timedelta(minutes=22)
4687 self.offset += timedelta(minutes=1)
4693 self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
4694 self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
4732 dt += timedelta(days_to_go)
4735 ZERO = timedelta(0)
4736 MINUTE = timedelta(minutes=1)
4737 HOUR = timedelta(hours=1)
4738 DAY = timedelta(days=1)
4750 self.stdoffset = timedelta(hours=hours)
4877 for delta in (timedelta(weeks=13),
4880 timedelta(minutes=1),
4881 timedelta(microseconds=1)):
4917 fourback = self.dston - timedelta(hours=4)
4948 first_std_hour = self.dstoff - timedelta(hours=2) # 23:MM
5019 expected -= timedelta(days=1)
5100 timedelta(),
5102 timezone(timedelta())]:
5193 self.stdoffset = timedelta(hours=hours)
5487 dt_summer = datetime(2002, 10, 27, 1, tzinfo=Eastern2) - timedelta.resolution
5514 dt_summer = datetime(2002, 10, 27, 1, tzinfo=Eastern2) - timedelta.resolution
5524 u_summer = datetime(2002, 10, 27, 6, tzinfo=Eastern2) - timedelta.resolution
5581 SEC = timedelta(0, 1)
5642 ttis[i] = (timedelta(0, gmtoff), isdst, abbr)
5683 fold = (shift > timedelta(0, timestamp - self.ut[idx-1]))
5732 min_gap = min_fold = timedelta.max
5838 for x in [0 * shift, 0.5 * shift, shift - timedelta.resolution]:
5851 for x in [-timedelta.resolution, shift]:
5860 for x in [0 * shift, 0.5 * shift, shift - timedelta.resolution]:
5875 for x in [-timedelta.resolution, shift]:
5962 exp_named = timezone(timedelta(hours=-5), "EST")
5963 exp_unnamed = timezone(timedelta(hours=-5))
5986 class TimeDeltaSubclass(timedelta):
5989 for klass in [timedelta, TimeDeltaSubclass]:
6056 non_utc_exp = timezone(timedelta(hours=0), "")
6088 timedelta(1), timezone.utc, time(12, 00)]
6113 timedelta(1), timezone.utc, date(2011, 1, 1)]
6139 timedelta(1), timezone.utc, date(2011, 1, 1)]
6147 class TimeDeltaSubclass(timedelta):
6150 td = timedelta(1)
6178 tz = timezone(timedelta(hours=-5))
6283 exp_delta = timedelta(26, 55, 99999)
6308 ((1995, 4, 12), timezone(timedelta(hours=1)), True),
6311 ((1995, 4, 12, 14, 30), timezone(timedelta(hours=1)), True),