• Home
  • Raw
  • Download

Lines Matching refs:tzinfo

28 from datetime import tzinfo
115 class FixedOffset(tzinfo):
142 class _TZInfo(tzinfo):
158 useless = tzinfo()
165 class NotEnough(tzinfo):
169 self.assertTrue(issubclass(NotEnough, tzinfo))
171 self.assertIsInstance(ne, tzinfo)
180 self.assertIsInstance(fo, tzinfo)
190 orig = tzinfo.__new__(tzinfo)
191 self.assertIs(type(orig), tzinfo)
195 self.assertIs(type(derived), tzinfo)
206 self.assertIsInstance(orig, tzinfo)
213 self.assertIsInstance(derived, tzinfo)
221 class UKSummerTime(tzinfo):
236 u = datetime(2014, 4, 26, 12, 1, tzinfo=tz)
286 self.assertIsInstance(timezone.utc, tzinfo)
287 self.assertIsInstance(self.EST, tzinfo)
334 utctime = self.DT.replace(tzinfo=tz)
338 self.DT.replace(tzinfo=timezone.utc))
366 t.replace(tzinfo=tz).tzname())
368 t.replace(tzinfo=tz).utcoffset())
370 t.replace(tzinfo=tz).dst())
426 self.assertNotEqual(timezone.utc, tzinfo())
427 self.assertNotEqual(timezone(timedelta(hours=1)), tzinfo())
2017 t = self.theclass(1, 2, 3, 4, 5, 1, 999500, tzinfo=timezone.utc)
2036 t = self.theclass(2, 3, 2, tzinfo=tz)
2064 dt = dt_base.replace(tzinfo=tzi)
2420 t = self.theclass(1970, 1, 1, tzinfo=timezone.utc)
2422 t = self.theclass(1970, 1, 1, 1, 2, 3, 4, tzinfo=timezone.utc)
2426 tzinfo=timezone(timedelta(hours=-5), 'EST'))
2473 min_dt = self.theclass.min.replace(tzinfo=timezone.utc)
2485 max_dt = self.theclass.max.replace(tzinfo=timezone.utc,
2608 self.assertEqual(strptime("UTC", "%Z").tzinfo, None)
2677 t = t.replace(tzinfo=tz)
2717 self.assertIs(dt.tzinfo, timezone.utc)
2718 dt = combine(d, t, tzinfo=timezone.utc)
2719 self.assertIs(dt.tzinfo, timezone.utc)
2754 dt_utc = dt.replace(tzinfo=timezone(timedelta(hours=-4), 'EDT'))
2758 dt_f = dt.replace(tzinfo=f) + timedelta(hours=4, minutes=44)
2762 class Bogus(tzinfo):
2767 self.assertEqual(dt.replace(tzinfo=bog).astimezone(f), dt_f)
2769 class AlsoBogus(tzinfo):
2775 class Broken(tzinfo):
2779 dt_broken = dt.replace(tzinfo=broken)
2905 dts = [self.theclass(*date_tuple, *time_tuple, tzinfo=tzi)
2936 dt = base_dt.replace(tzinfo=tzi)
2991 dt = self.theclass(*(dt_tuple[0:(4 + ip)]), tzinfo=tzi)
3047 self.assertIs(dt.tzinfo, timezone.utc)
3054 tzinfo=timezone(timedelta(hours=10, minutes=45)))
3272 t = t_base.replace(tzinfo=tzi)
3473 class introspective(tzinfo):
3479 obj = cls(1, 2, 3, tzinfo=introspective())
3490 self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=12)
3495 self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=NiceTry)
3497 class BetterTry(tzinfo):
3501 t = cls(1, 1, 1, tzinfo=b)
3502 self.assertIs(t.tzinfo, b)
3505 class Edgy(tzinfo):
3517 t = cls(1, 2, 3, tzinfo=Edgy(offset))
3519 t = cls(6, 6, 6, 1, 2, 3, tzinfo=Edgy(offset))
3534 class C1(tzinfo):
3539 cls(1, 1, 1, tzinfo=None),
3540 cls(1, 1, 1, tzinfo=C1())):
3545 class C3(tzinfo):
3549 t = cls(1, 1, 1, tzinfo=C3())
3555 class C4(tzinfo):
3559 t = cls(1, 1, 1, tzinfo=C4())
3565 class C6(tzinfo):
3568 t = cls(1, 1, 1, tzinfo=C6())
3573 class C7(tzinfo):
3576 t = cls(1, 1, 1, tzinfo=C7())
3585 class OperandDependentOffset(tzinfo):
3594 base = cls(8, 9, 10, tzinfo=OperandDependentOffset())
3610 d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
3611 d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
3612 d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
3638 self.assertIsNone(t.tzinfo)
3644 t1 = time( 7, 47, tzinfo=est)
3645 t2 = time(12, 47, tzinfo=utc)
3646 t3 = time(13, 47, tzinfo=met)
3648 t5 = time(microsecond=40, tzinfo=utc)
3650 self.assertEqual(t1.tzinfo, est)
3651 self.assertEqual(t2.tzinfo, utc)
3652 self.assertEqual(t3.tzinfo, met)
3653 self.assertIsNone(t4.tzinfo)
3654 self.assertEqual(t5.tzinfo, utc)
3710 t1 = time(23, 59, tzinfo=yuck)
3715 class Badtzname(tzinfo):
3718 t = time(2, 3, 4, tzinfo=Badtzname())
3729 t1 = self.theclass(0, 1, 2, 3, tzinfo=FixedOffset(1439, ""))
3730 t2 = self.theclass(0, 0, 2, 3, tzinfo=FixedOffset(1438, ""))
3733 t1 = self.theclass(23, 58, 6, 100, tzinfo=FixedOffset(-1000, ""))
3734 t2 = self.theclass(23, 48, 6, 100, tzinfo=FixedOffset(-1010, ""))
3749 orig = self.theclass(5, 6, 7, tzinfo=tinfo)
3754 self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
3784 expected = self.theclass(5, 6, 7, 123456, tzinfo=tinfo)
3789 self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
3797 t = cls(0, tzinfo=FixedOffset(-300, ""))
3800 t = cls(5, tzinfo=FixedOffset(-300, ""))
3803 t = cls(5, tzinfo=FixedOffset(300, ""))
3806 t = cls(23, 59, tzinfo=FixedOffset(23*60 + 59, ""))
3832 base2 = base.replace(tzinfo=None)
3833 self.assertIsNone(base2.tzinfo)
3837 base3 = base2.replace(tzinfo=z100)
3839 self.assertIs(base.tzinfo, base3.tzinfo)
3852 t2 = t2.replace(tzinfo=None)
3854 t2 = t2.replace(tzinfo=FixedOffset(None, ""))
3856 t2 = t2.replace(tzinfo=FixedOffset(0, ""))
3860 class Varies(tzinfo):
3868 t1 = t2.replace(tzinfo=v)
3869 t2 = t2.replace(tzinfo=v)
3875 t2 = t2.replace(tzinfo=Varies())
3897 t = self.theclass(*ttup, tzinfo=tzi)
3922 t = base_time.replace(tzinfo=tzi)
3950 t = self.theclass(*(t_tuple[0:(1 + ip)]), tzinfo=tzi)
4000 tsc = TimeSubclass(12, 14, 45, 203745, tzinfo=timezone.utc)
4047 self.assertEqual(dt.tzinfo, None)
4054 t1 = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
4057 tzinfo=FixedOffset(-1439, ""))
4068 t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""))
4069 t2 = self.theclass(2, 1, 1, 3, 13, tzinfo=FixedOffset(3*60+13+2, ""))
4073 t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(0, ""))
4077 t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(2, ""))
4081 t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
4086 t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
4099 class Naive(tzinfo):
4101 t2 = self.theclass(5, 6, 7, tzinfo=Naive())
4111 class Bogus(tzinfo):
4114 t1 = self.theclass(2, 2, 2, tzinfo=Bogus())
4115 t2 = self.theclass(2, 2, 2, tzinfo=FixedOffset(0, ""))
4131 derived = self.theclass(1, 1, 1, tzinfo=FixedOffset(0, "", 0))
4136 self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
4174 self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
4182 t = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
4185 tzinfo=FixedOffset(-1439, ""))
4189 t = self.theclass(5, 5, 5, tzinfo=FixedOffset(-1440, ""))
4196 t1 = datetime(2002, 3, 19, 7, 47, tzinfo=est)
4197 t2 = datetime(2002, 3, 19, 12, 47, tzinfo=utc)
4198 t3 = datetime(2002, 3, 19, 13, 47, tzinfo=met)
4199 self.assertEqual(t1.tzinfo, est)
4200 self.assertEqual(t2.tzinfo, utc)
4201 self.assertEqual(t3.tzinfo, met)
4225 tz = time(18, 45, 3, 1234, tzinfo=met)
4228 tzinfo=met))
4232 dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234, tzinfo=met)
4235 self.assertEqual(dt.timetz(), time(18, 45, 3, 1234, tzinfo=met))
4240 timeaware = now.time().replace(tzinfo=tz55)
4242 self.assertIs(nowaware.tzinfo, tz55)
4261 self.assertIs(nowaware.tzinfo, tz55)
4263 self.assertIs(nowawareplus2.tzinfo, tz55)
4269 self.assertIs(diff.tzinfo, tz55)
4277 nowawareplus = nowawareplus.replace(tzinfo=tzr)
4278 self.assertIs(nowawareplus.tzinfo, tzr)
4290 min = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, "min"))
4292 tzinfo=FixedOffset(-1439, "max"))
4299 delta = min.replace(tzinfo=tza) - max.replace(tzinfo=tzb)
4310 self.assertIs(another.tzinfo, again.tzinfo)
4314 self.assertRaises(TypeError, meth, tzinfo=16)
4328 self.assertIs(now.tzinfo, weirdtz)
4329 utcnow = datetime.utcnow().replace(tzinfo=utc)
4349 self.assertIs(another.tzinfo, again.tzinfo)
4353 self.assertRaises(TypeError, meth, ts, tzinfo=16)
4372 self.assertEqual(expected, got.replace(tzinfo=None))
4382 self.assertRaises(TypeError, meth, tzinfo=off42)
4394 self.assertRaises(TypeError, meth, ts, tzinfo=off42)
4399 class DST(tzinfo):
4409 d = cls(1, 1, 1, 10, 20, 30, 40, tzinfo=DST(dstvalue))
4422 self.assertRaises(TypeError, cls(1, 1, 1, tzinfo=DST("x")).timetuple)
4425 self.assertEqual(cls(1,1,1, tzinfo=DST(1439)).timetuple().tm_isdst, 1)
4426 self.assertEqual(cls(1,1,1, tzinfo=DST(-1439)).timetuple().tm_isdst, 1)
4429 self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(1440)).timetuple)
4430 self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(-1440)).timetuple)
4433 class DST(tzinfo):
4444 cls(1, 1, 1, tzinfo=DST(0)).utcoffset)
4454 d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=UOFS(-53, dstvalue))
4478 d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=NOFS())
4486 d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=BOFS())
4493 dtz = d.replace(tzinfo=tz)
4499 tiny = cls(MINYEAR, 1, 1, 0, 0, 37, tzinfo=UOFS(1439))
4503 huge = cls(MAXYEAR, 12, 31, 23, 59, 37, 999999, tzinfo=UOFS(-1439))
4507 tiny = cls.min.replace(tzinfo=timezone(MINUTE))
4509 huge = cls.max.replace(tzinfo=timezone(-MINUTE))
4522 d = cls(1, 2, 3, 4, 5, 59, us, tzinfo=ofs)
4559 base2 = base.replace(tzinfo=None)
4560 self.assertIsNone(base2.tzinfo)
4564 base3 = base2.replace(tzinfo=z100)
4566 self.assertIs(base.tzinfo, base3.tzinfo)
4579 self.assertIs(dt.tzinfo, f44m)
4583 x = dt.astimezone(dt.tzinfo)
4584 self.assertIs(x.tzinfo, f44m)
4590 self.assertIs(got.tzinfo, fm5h)
4594 expected = expected.replace(tzinfo=fm5h) # and attach new tzinfo
4598 self.assertIs(got.tzinfo, expected.tzinfo)
4611 dt = self.theclass(2012, 11, 4, 6, 30, tzinfo=timezone.utc)
4615 dt = self.theclass(2012, 11, 4, 5, 30, tzinfo=timezone.utc)
4623 u = datetime(2015, 11, 1, 5, tzinfo=timezone.utc)
4626 self.assertEqual(t.tzinfo, s.tzinfo)
4633 class OperandDependentOffset(tzinfo):
4642 base = cls(8, 9, 10, 11, 12, 13, 14, tzinfo=OperandDependentOffset())
4655 d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
4656 d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
4657 d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
4676 t2 = t2.replace(tzinfo=None)
4678 t2 = t2.replace(tzinfo=FixedOffset(None, ""))
4680 t2 = t2.replace(tzinfo=FixedOffset(0, ""))
4684 class Varies(tzinfo):
4692 t1 = t2.replace(tzinfo=v)
4693 t2 = t2.replace(tzinfo=v)
4699 t2 = t2.replace(tzinfo=Varies())
4748 class USTimeZone(tzinfo):
4769 if dt is None or dt.tzinfo is None:
4773 assert dt.tzinfo is self
4785 if start <= dt.replace(tzinfo=None) < end:
4871 dston = self.dston.replace(tzinfo=tz)
4877 dstoff = self.dstoff.replace(tzinfo=tz)
4920 fourback = fourback.replace(tzinfo=ninewest)
4929 got = fourback.astimezone(Eastern).replace(tzinfo=None)
4934 sixutc = self.dston.replace(hour=6, tzinfo=utc_real)
4939 got = sixutc.astimezone(Eastern).replace(tzinfo=None)
4956 asutcbase = asutc.replace(tzinfo=utc)
4963 self.assertEqual(astz.replace(tzinfo=None), expected)
4968 class ok(tzinfo):
4972 now = self.theclass.now().replace(tzinfo=utc_real)
4991 dt = self.theclass(2001, 1, 1).replace(tzinfo=utc_real)
4996 now = datetime.utcnow().replace(tzinfo=utc_real)
4998 now = now.replace(tzinfo=Eastern) # insert correct tzinfo
5000 self.assertEqual(enow.tzinfo, Eastern) # has right tzinfo member
5015 start = self.dston.replace(hour=4, tzinfo=Eastern)
5016 fstart = start.replace(tzinfo=FEastern)
5029 got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
5036 start = self.dstoff.replace(hour=4, tzinfo=Eastern)
5037 fstart = start.replace(tzinfo=FEastern)
5048 got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
5102 tzinfo(),
5135 class tzinfo2(tzinfo):
5142 if dt.tzinfo is not self:
5190 if dt is None or dt.tzinfo is None:
5194 assert dt.tzinfo is self
5206 dt = dt.replace(tzinfo=None)
5237 class Europe_Vilnius_1941(tzinfo):
5239 return [datetime(1941, 6, 23, 21, tzinfo=self), # Mon Jun 23 21:00:00 1941 UTC
5240 datetime(1941, 6, 23, 22, tzinfo=self)] # Mon Jun 23 22:00:00 1941 UTC
5243 return [datetime(1941, 6, 23, 23, tzinfo=self), # Mon Jun 23 23:00:00 1941 MSK / CEST
5244 datetime(1941, 6, 24, 0, tzinfo=self)] # Mon Jun 24 00:00:00 1941 CEST
5275 assert dt.tzinfo is self
5292 gdt = datetime(1941, 6, 23, 20, 59, 59, tzinfo=timezone.utc)
5299 gdt = datetime(1941, 6, 23, 21, tzinfo=timezone.utc)
5306 gdt = datetime(1941, 6, 23, 22, tzinfo=timezone.utc)
5316 ldt = datetime(1941, 6, 23, 22, 59, 59, tzinfo=Vilnius)
5321 ldt = datetime(1941, 6, 23, 23, 59, 59, tzinfo=Vilnius)
5326 ldt = datetime(1941, 6, 23, 23, 59, 59, tzinfo=Vilnius, fold=1)
5331 ldt = datetime(1941, 6, 24, 0, tzinfo=Vilnius)
5359 t = t.replace(fold=1, tzinfo=Eastern)
5360 dt = dt.replace(fold=1, tzinfo=Eastern)
5361 self.assertEqual(t.replace(tzinfo=None).fold, 1)
5362 self.assertEqual(dt.replace(tzinfo=None).fold, 1)
5466 dt_summer = datetime(2002, 10, 27, 1, tzinfo=Eastern2) - timedelta.resolution
5467 dt_winter = datetime(2002, 10, 27, 2, tzinfo=Eastern2)
5476 dt = datetime(2002, 10, 27, 1, minute, tzinfo=Eastern2)
5484 dt = datetime(2002, 4, 7, 2, minute, tzinfo=Eastern2)
5493 dt_summer = datetime(2002, 10, 27, 1, tzinfo=Eastern2) - timedelta.resolution
5494 dt_winter = datetime(2002, 10, 27, 2, tzinfo=Eastern2)
5503 u_summer = datetime(2002, 10, 27, 6, tzinfo=Eastern2) - timedelta.resolution
5504 u_winter = datetime(2002, 10, 27, 7, tzinfo=Eastern2)
5513 u = datetime(2002, 10, 27, 5, 30, tzinfo=Eastern2)
5521 u = datetime(2002, 10, 27, 1, 30, tzinfo=Eastern2)
5525 u = datetime(2002, 10, 27, 6, 30, tzinfo=Eastern2)
5530 u = datetime(2002, 4, 7, 2, 0, tzinfo=Eastern2)
5535 t = datetime(2000, 1, 1, tzinfo=Eastern2)
5537 t = datetime(2000, 6, 1, tzinfo=Eastern2)
5541 t_fold = datetime(2002, 10, 27, 1, 45, tzinfo=Eastern2)
5547 t_gap = datetime(2002, 4, 7, 2, 45, tzinfo=Eastern2)
5553 t = datetime(2000, 1, 1, tzinfo=Eastern2)
5555 t_fold = datetime(2002, 10, 27, 1, 45, tzinfo=Eastern2)
5556 t_gap = datetime(2002, 4, 7, 2, 45, tzinfo=Eastern2)
5567 class ZoneInfo(tzinfo):
5644 if dt.tzinfo is not self:
5811 self.assertEqual((a.replace(tzinfo=None), a.fold, id(a.tzinfo)),
5812 (b.replace(tzinfo=None), b.fold, id(b.tzinfo)))
5819 ldt = tz.fromutc(udt.replace(tzinfo=tz))
5821 adt = udt.replace(tzinfo=timezone.utc).astimezone(tz)
5824 self.assertEqual(ldt.replace(tzinfo=None), udt + utcoffset)
5827 udt.replace(tzinfo=timezone.utc))
5832 udt = udt.replace(tzinfo=tz)
5841 udt = udt.replace(tzinfo=tz)
5844 adt = udt.replace(tzinfo=timezone.utc).astimezone(tz)
5847 self.assertEqual(ldt.replace(tzinfo=None), udt.replace(tzinfo=None) + utcoffset)
5849 ldt = tz.fromutc(dt.replace(tzinfo=tz)) - shift + x
5856 ldt = tz.fromutc(udt.replace(tzinfo=tz))
5885 tzdt = datetime.fromtimestamp(s, tz).replace(tzinfo=None)
5954 dt1 = datetime(2000, 2, 4, tzinfo=tz_act)
5955 dt2 = datetime(2000, 2, 4, tzinfo=tz_exp)
5960 dt_utc = datetime(2000, 2, 4, 5, tzinfo=timezone.utc)
6002 hour, minute, second, microsecond, tzinfo = \
6009 self.assertIs(tzinfo, d.tzinfo)
6020 hour, minute, second, microsecond, tzinfo = \
6027 self.assertIs(tzinfo, d.tzinfo)
6045 dt1 = datetime(2000, 2, 4, tzinfo=non_utc)
6046 dt2 = datetime(2000, 2, 4, tzinfo=non_utc_exp)
6158 class TZInfoSubclass(tzinfo):
6161 tzi = tzinfo()
6303 dtup, tzinfo, usetz = case
6304 dt_orig = datetime(*dtup, tzinfo=tzinfo)
6307 dt_rt = from_timestamp(ts, tzinfo, usetz, macro)