• Home
  • Raw
  • Download

Lines Matching refs:dt

127     def utcoffset(self, dt):  argument
129 def tzname(self, dt): argument
131 def dst(self, dt): argument
159 dt = datetime.max
160 self.assertRaises(NotImplementedError, useless.tzname, dt)
161 self.assertRaises(NotImplementedError, useless.utcoffset, dt)
162 self.assertRaises(NotImplementedError, useless.dst, dt)
173 dt = datetime.now()
174 self.assertRaises(NotImplementedError, ne.tzname, dt)
175 self.assertRaises(NotImplementedError, ne.utcoffset, dt)
176 self.assertRaises(NotImplementedError, ne.dst, dt)
181 for dt in datetime.now(), None:
182 self.assertEqual(fo.utcoffset(dt), timedelta(minutes=3))
183 self.assertEqual(fo.tzname(dt), "Three")
184 self.assertEqual(fo.dst(dt), timedelta(minutes=42))
226 def utcoffset(self, dt): argument
229 def dst(self, dt): argument
232 def tzname(self, dt): argument
1058 dt = date(2000, 1, 2)
1064 dt2 = dt + delta
1065 self.assertEqual(dt2, dt + days)
1067 dt2 = delta + dt
1068 self.assertEqual(dt2, dt + days)
1070 dt2 = dt - delta
1071 self.assertEqual(dt2, dt - days)
1077 dt2 = dt + delta
1078 self.assertEqual(dt2, dt + days)
1080 dt2 = delta + dt
1081 self.assertEqual(dt2, dt + days)
1083 dt2 = dt - delta
1084 self.assertEqual(dt2, dt - days)
1096 dt = self.theclass(2002, 3, 1)
1097 self.assertEqual(dt.year, 2002)
1098 self.assertEqual(dt.month, 3)
1099 self.assertEqual(dt.day, 1)
1102 for dt in (self.theclass(1, 2, 3),
1105 s = repr(dt)
1109 self.assertEqual(dt, dt2)
1112 dt2 = self.theclass(dt.year, dt.month, dt.day)
1113 self.assertEqual(dt, dt2)
1288 dt = self.theclass.min + delta
1289 dt -= delta # no problem
1290 self.assertRaises(OverflowError, dt.__sub__, delta)
1291 self.assertRaises(OverflowError, dt.__add__, -delta)
1293 dt = self.theclass.max - delta
1294 dt += delta # no problem
1295 self.assertRaises(OverflowError, dt.__add__, delta)
1296 self.assertRaises(OverflowError, dt.__sub__, -delta)
1499 dt = self.theclass(2007, 9, 10)
1500 self.assertEqual(dt.__format__(''), str(dt))
1503 dt.__format__(123)
1517 self.assertEqual(b.__format__(''), str(dt))
1523 self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
1524 self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
1703 dt = DateSubclass(2012, 1, 1)
1704 self.assertIs(type(dt.replace(year=2013)), DateSubclass)
1765 dt = constr(*constr_args)
1768 self.assertIsInstance(dt, DateSubclass)
1771 self.assertEqual(dt, base_d)
1774 self.assertEqual(dt.extra, 7)
1825 dt = self.theclass(*dt_tuple)
1826 dt_str = dt.isoformat()
1828 dt_rt = self.theclass.fromisoformat(dt.isoformat())
1830 self.assertEqual(dt, dt_rt)
1836 dt = DateSubclass(2014, 12, 14)
1838 dt_rt = DateSubclass.fromisoformat(dt.isoformat())
1958 dt = self.theclass(2002, 3, 1, 12, 0)
1959 self.assertEqual(dt.year, 2002)
1960 self.assertEqual(dt.month, 3)
1961 self.assertEqual(dt.day, 1)
1962 self.assertEqual(dt.hour, 12)
1963 self.assertEqual(dt.minute, 0)
1964 self.assertEqual(dt.second, 0)
1965 self.assertEqual(dt.microsecond, 0)
1970 dt = self.theclass(2002, 3, 1, 12, 59, 59, 8000)
1971 self.assertEqual(dt.year, 2002)
1972 self.assertEqual(dt.month, 3)
1973 self.assertEqual(dt.day, 1)
1974 self.assertEqual(dt.hour, 12)
1975 self.assertEqual(dt.minute, 59)
1976 self.assertEqual(dt.second, 59)
1977 self.assertEqual(dt.microsecond, 8000)
1980 for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7),
1983 s = repr(dt)
1987 self.assertEqual(dt, dt2)
1990 dt2 = self.theclass(dt.year, dt.month, dt.day,
1991 dt.hour, dt.minute, dt.second,
1992 dt.microsecond)
1993 self.assertEqual(dt, dt2)
2064 dt = dt_base.replace(tzinfo=tzi)
2067 assert dt.isoformat() == exp
2070 dt = self.theclass(2007, 9, 10, 4, 5, 1, 123)
2071 self.assertEqual(dt.__format__(''), str(dt))
2074 dt.__format__(123)
2088 self.assertEqual(b.__format__(''), str(dt))
2094 self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
2095 self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
2135 def tzname(self, dt): argument
2596 dt = strptime(dtstr, "%z %Z")
2597 self.assertEqual(dt.utcoffset(), timedelta(seconds=tzseconds))
2598 self.assertEqual(dt.tzname(), tzname)
2601 dt = strptime(dtstr, fmt)
2602 self.assertEqual(dt.utcoffset(), 12 * HOUR + 34 * MINUTE)
2603 self.assertEqual(dt.tzname(), 'UTC')
2605 self.assertEqual(dt.strftime(fmt), dtstr)
2687 dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
2688 self.assertEqual(dt.date(), date(2002, 3, 4))
2689 self.assertEqual(dt.time(), time(18, 45, 3, 1234))
2696 dt = combine(d, t)
2697 self.assertEqual(dt, expected)
2699 dt = combine(time=t, date=d)
2700 self.assertEqual(dt, expected)
2702 self.assertEqual(d, dt.date())
2703 self.assertEqual(t, dt.time())
2704 self.assertEqual(dt, combine(dt.date(), dt.time()))
2716 dt = combine(d, t, timezone.utc)
2717 self.assertIs(dt.tzinfo, timezone.utc)
2718 dt = combine(d, t, tzinfo=timezone.utc)
2719 self.assertIs(dt.tzinfo, timezone.utc)
2721 dt = combine(dt, t)
2722 self.assertEqual(dt.date(), d)
2723 self.assertEqual(dt.time(), t)
2752 dt = self.theclass.now()
2754 dt_utc = dt.replace(tzinfo=timezone(timedelta(hours=-4), 'EDT'))
2755 self.assertEqual(dt.astimezone(), dt_utc) # naive
2756 self.assertRaises(TypeError, dt.astimezone, f, f) # too many args
2757 self.assertRaises(TypeError, dt.astimezone, dt) # arg wrong type
2758 dt_f = dt.replace(tzinfo=f) + timedelta(hours=4, minutes=44)
2759 self.assertEqual(dt.astimezone(f), dt_f) # naive
2760 self.assertEqual(dt.astimezone(tz=f), dt_f) # naive
2763 def utcoffset(self, dt): return None argument
2764 def dst(self, dt): return timedelta(0) argument
2766 self.assertRaises(ValueError, dt.astimezone, bog) # naive
2767 self.assertEqual(dt.replace(tzinfo=bog).astimezone(f), dt_f)
2770 def utcoffset(self, dt): return timedelta(0) argument
2771 def dst(self, dt): return None argument
2773 self.assertRaises(ValueError, dt.astimezone, alsobog) # also naive
2776 def utcoffset(self, dt): return 1 argument
2777 def dst(self, dt): return 1 argument
2779 dt_broken = dt.replace(tzinfo=broken)
2848 dt = constructor(*constr_args)
2851 self.assertIsInstance(dt, DateTimeSubclass)
2854 self.assertEqual(dt, expected)
2857 self.assertEqual(dt.extra, 7)
2878 dt = constr(**kwargs)
2880 self.assertIsInstance(dt, DateTimeSubclass)
2881 self.assertEqual(dt.extra, 7)
2910 for dt in dts:
2912 dtstr = dt.isoformat(sep=sep)
2916 self.assertEqual(dt, dt_rt)
2936 dt = base_dt.replace(tzinfo=tzi)
2937 dtstr = dt.isoformat()
2941 assert dt == dt_rt, dt_rt
2953 dt = self.theclass(2018, 1, 31, 23, 59, 47, 124789)
2954 dtstr = dt.isoformat(sep=sep)
2958 self.assertEqual(dt, dt_rt)
2964 dt = self.theclass(2018, 1, 31, 12, 15)
2965 dtstr = dt.isoformat(sep=sep)
2969 self.assertEqual(dt, dt_rt)
2991 dt = self.theclass(*(dt_tuple[0:(4 + ip)]), tzinfo=tzi)
2992 dtstr = dt.isoformat(timespec=ts)
2995 self.assertEqual(dt, dt_rt)
3045 dt = self.theclass.fromisoformat(dt_str)
3047 self.assertIs(dt.tzinfo, timezone.utc)
3053 dt = DateTimeSubclass(2014, 12, 14, 9, 30, 45, 457390,
3056 dt_rt = DateTimeSubclass.fromisoformat(dt.isoformat())
3058 self.assertEqual(dt, dt_rt)
3474 def tzname(self, dt): return dt and "real" or "none" argument
3475 def utcoffset(self, dt): argument
3476 return timedelta(minutes = dt and 42 or -42)
3494 def utcoffset(self, dt): pass argument
3499 def utcoffset(self, dt): pass argument
3508 def utcoffset(self, dt): argument
3535 def utcoffset(self, dt): return None argument
3536 def dst(self, dt): return None argument
3537 def tzname(self, dt): return None argument
3546 def utcoffset(self, dt): return timedelta(minutes=-1439) argument
3547 def dst(self, dt): return timedelta(minutes=1439) argument
3548 def tzname(self, dt): return "aname" argument
3556 def utcoffset(self, dt): return "aname" argument
3557 def dst(self, dt): return 7 argument
3558 def tzname(self, dt): return 0 argument
3566 def utcoffset(self, dt): return timedelta(hours=-24) argument
3567 def dst(self, dt): return timedelta(hours=24) argument
3574 def utcoffset(self, dt): return timedelta(microseconds=61) argument
3575 def dst(self, dt): return timedelta(microseconds=-81) argument
3717 def tzname(self, dt): return self.tz argument
4039 dt = self.theclass(1, 2, 3, 4, 5, 6, 7)
4040 self.assertEqual(dt.year, 1)
4041 self.assertEqual(dt.month, 2)
4042 self.assertEqual(dt.day, 3)
4043 self.assertEqual(dt.hour, 4)
4044 self.assertEqual(dt.minute, 5)
4045 self.assertEqual(dt.second, 6)
4046 self.assertEqual(dt.microsecond, 7)
4047 self.assertEqual(dt.tzinfo, None)
4100 def utcoffset(self, dt): return None argument
4112 def utcoffset(self, dt): argument
4226 dt = datetime.combine(d, tz)
4227 self.assertEqual(dt, datetime(2002, 3, 4, 18, 45, 3, 1234,
4232 dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234, tzinfo=met)
4233 self.assertEqual(dt.date(), date(2002, 3, 4))
4234 self.assertEqual(dt.time(), time(18, 45, 3, 1234))
4235 self.assertEqual(dt.timetz(), time(18, 45, 3, 1234, tzinfo=met))
4404 def dst(self, dt): argument
4438 def dst(self, dt): argument
4450 def utcoffset(self, dt): argument
4476 def utcoffset(self, dt): argument
4484 def utcoffset(self, dt): argument
4578 dt = self.theclass.now(tz=f44m)
4579 self.assertIs(dt.tzinfo, f44m)
4581 self.assertRaises(ValueError, dt.astimezone, fnone)
4583 x = dt.astimezone(dt.tzinfo)
4585 self.assertEqual(x.date(), dt.date())
4586 self.assertEqual(x.time(), dt.time())
4589 got = dt.astimezone(fm5h)
4592 expected = dt - dt.utcoffset() # in effect, convert to UTC
4593 expected += fm5h.utcoffset(dt) # and from there to local time
4603 dt = self.theclass.now(timezone.utc)
4604 self.assertEqual(dt.astimezone(None), dt)
4605 self.assertEqual(dt.astimezone(), dt)
4611 dt = self.theclass(2012, 11, 4, 6, 30, tzinfo=timezone.utc)
4612 local = dt.astimezone()
4613 self.assertEqual(dt, local)
4615 dt = self.theclass(2012, 11, 4, 5, 30, tzinfo=timezone.utc)
4616 local = dt.astimezone()
4617 self.assertEqual(dt, local)
4730 def first_sunday_on_or_after(dt): argument
4731 days_to_go = 6 - dt.weekday()
4733 dt += timedelta(days_to_go)
4734 return dt
4759 def tzname(self, dt): argument
4760 if self.dst(dt):
4765 def utcoffset(self, dt): argument
4766 return self.stdoffset + self.dst(dt)
4768 def dst(self, dt): argument
4769 if dt is None or dt.tzinfo is None:
4773 assert dt.tzinfo is self
4776 start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
4780 end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
4785 if start <= dt.replace(tzinfo=None) < end:
4807 def checkinside(self, dt, tz, utc, dston, dstoff): argument
4808 self.assertEqual(dt.dst(), HOUR)
4811 self.assertEqual(dt.astimezone(tz), dt)
4813 asutc = dt.astimezone(utc)
4824 if dt.date() == dston.date() and dt.hour == 2:
4827 self.assertEqual(there_and_back + HOUR, dt)
4833 dt.astimezone(utc))
4836 self.assertEqual(dt, there_and_back)
4848 if dt.date() == dstoff.date() and dt.hour == 0:
4851 self.assertEqual(nexthour_tz, dt.replace(hour=1))
4854 self.assertEqual(nexthour_tz, dt.replace(hour=1))
4856 self.assertEqual(nexthour_tz - dt, HOUR)
4859 def checkoutside(self, dt, tz, utc): argument
4860 self.assertEqual(dt.dst(), ZERO)
4863 self.assertEqual(dt.astimezone(tz), dt)
4866 asutc = dt.astimezone(utc)
4868 self.assertEqual(dt, there_and_back)
4969 def utcoffset(self, dt): return HOUR argument
4970 def dst(self, dt): return HOUR argument
4978 def dst(self, dt): return None argument
4986 def dst(self, dt): argument
4987 if dt.year == 2000:
4991 dt = self.theclass(2001, 1, 1).replace(tzinfo=utc_real)
4992 self.assertRaises(ValueError, dt.astimezone, tricky_notok())
5006 def fromutc(self, dt): argument
5007 return dt + self.stdoffset
5137 def fromutc(self, dt): argument
5140 if not isinstance(dt, datetime):
5142 if dt.tzinfo is not self:
5146 off0 = dt.replace(fold=0).utcoffset()
5147 off1 = dt.replace(fold=1).utcoffset()
5148 if off0 is None or off1 is None or dt.dst() is None:
5151 ldt = dt + off0
5158 ldt = dt + off
5180 def tzname(self, dt): argument
5181 if self.dst(dt):
5186 def utcoffset(self, dt): argument
5187 return self.stdoffset + self.dst(dt)
5189 def dst(self, dt): argument
5190 if dt is None or dt.tzinfo is None:
5194 assert dt.tzinfo is self
5197 start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
5201 end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
5206 dt = dt.replace(tzinfo=None)
5207 if start + HOUR <= dt < end:
5210 elif end <= dt < end + HOUR:
5212 return ZERO if dt.fold else HOUR
5213 elif start <= dt < start + HOUR:
5215 return HOUR if dt.fold else ZERO
5246 def utcoffset(self, dt): argument
5248 if dt < fold_start:
5250 if dt < fold_stop:
5251 return (2 if dt.fold else 3) * HOUR
5255 def dst(self, dt): argument
5257 if dt < fold_start:
5259 if dt < fold_stop:
5260 return (1 if dt.fold else 0) * HOUR
5264 def tzname(self, dt): argument
5266 if dt < fold_start:
5268 if dt < fold_stop:
5269 return ('MSK', 'CEST')[dt.fold]
5273 def fromutc(self, dt): argument
5274 assert dt.fold == 0
5275 assert dt.tzinfo is self
5276 if dt.year != 1941:
5279 if dt < fold_start:
5280 return dt + 3 * HOUR
5281 if dt < fold_stop:
5282 return (dt + 2 * HOUR).replace(fold=1)
5284 return dt + 2 * HOUR
5338 dt = datetime(1, 1, 1, fold=1)
5340 self.assertEqual(dt.fold, 1)
5345 dt = datetime(1, 1, 1, fold=1)
5346 t = dt.time()
5348 t = dt.timetz()
5353 dt = datetime(1, 1, 1)
5355 self.assertEqual(dt.replace(fold=1).fold, 1)
5357 self.assertEqual(dt.replace(fold=0).fold, 0)
5360 dt = dt.replace(fold=1, tzinfo=Eastern)
5362 self.assertEqual(dt.replace(tzinfo=None).fold, 1)
5367 dt.replace(fold=2)
5372 dt.replace(1, 1, 1, 1, 1, 1, 1, None, 1)
5376 dt = datetime(1, 1, 1)
5378 self.assertEqual(dt, dt.replace(fold=1))
5382 dt = datetime(1, 1, 1)
5384 self.assertEqual(hash(dt), hash(dt.replace(fold=1)))
5449 dt = datetime(1, 1, 1, fold=1)
5451 for x in [t, dt]:
5459 dt = datetime(1, 1, 1, fold=1)
5461 self.assertEqual(repr(dt),
5476 dt = datetime(2002, 10, 27, 1, minute, tzinfo=Eastern2)
5478 self.assertEqual(dt.dst(), HOUR)
5480 self.assertEqual(dt.replace(fold=1).dst(), ZERO)
5484 dt = datetime(2002, 4, 7, 2, minute, tzinfo=Eastern2)
5486 self.assertEqual(dt.dst(), ZERO)
5488 self.assertEqual(dt.replace(fold=1).dst(), HOUR)
5639 def fromutc(self, dt): argument
5642 if not isinstance(dt, datetime):
5644 if dt.tzinfo is not self:
5647 timestamp = ((dt.toordinal() - self.EPOCHORDINAL) * 86400
5648 + dt.hour * 3600
5649 + dt.minute * 60
5650 + dt.second)
5663 dt += tti[0]
5665 return dt.replace(fold=1)
5667 return dt
5669 def _find_ti(self, dt, i): argument
5670 timestamp = ((dt.toordinal() - self.EPOCHORDINAL) * 86400
5671 + dt.hour * 3600
5672 + dt.minute * 60
5673 + dt.second)
5674 lt = self.lt[dt.fold]
5679 def utcoffset(self, dt): argument
5680 return self._find_ti(dt, 0)
5682 def dst(self, dt): argument
5683 isdst = self._find_ti(dt, 1)
5690 def tzname(self, dt): argument
5691 return self._find_ti(dt, 2)
5721 for dt, shift in tz.transitions():
5722 if dt < stats_since:
5726 if (shift, dt) > (max_gap, max_gap_datetime):
5729 max_gap_datetime = dt
5730 if (shift, datetime.max - dt) < (min_gap, datetime.max - min_gap_datetime):
5733 min_gap_datetime = dt
5737 if (shift, dt) > (max_fold, max_fold_datetime):
5740 max_fold_datetime = dt
5741 if (shift, datetime.max - dt) < (min_fold, datetime.max - min_fold_datetime):
5744 min_fold_datetime = dt
5774 for dt, shift, prev_abbr, abbr in tz.nondst_folds():
5775 if dt.year < start_year or same_abbr and prev_abbr != abbr:
5779 (count, zonename, dt, shift, prev_abbr, abbr))
5816 for dt, shift in tz.folds():
5818 udt = dt + x
5831 udt = dt + x
5838 for dt, shift in tz.gaps():
5840 udt = dt + x
5849 ldt = tz.fromutc(dt.replace(tzinfo=tz)) - shift + x
5855 udt = dt + x
5891 dt = datetime.fromtimestamp(s0) - shift / 2
5892 ts0 = dt.timestamp()
5893 ts1 = dt.replace(fold=1).timestamp()
6057 dt = datetime(2011, 1, 1)
6063 self.assertTrue(is_date(dt))
6068 self.assertFalse(is_date(dt, True))
6109 dt = datetime(2011, 1, 1, 12, 30)
6115 self.assertTrue(is_datetime(dt))
6117 self.assertTrue(is_datetime(dt, True))