Home | History | Annotate | Download | only in test

Lines Matching refs:dt

54     def utcoffset(self, dt):
56 def tzname(self, dt):
58 def dst(self, dt):
72 dt = datetime.max
73 self.assertRaises(NotImplementedError, useless.tzname, dt)
74 self.assertRaises(NotImplementedError, useless.utcoffset, dt)
75 self.assertRaises(NotImplementedError, useless.dst, dt)
86 dt = datetime.now()
87 self.assertRaises(NotImplementedError, ne.tzname, dt)
88 self.assertRaises(NotImplementedError, ne.utcoffset, dt)
89 self.assertRaises(NotImplementedError, ne.dst, dt)
94 for dt in datetime.now(), None:
95 self.assertEqual(fo.utcoffset(dt), timedelta(minutes=3))
96 self.assertEqual(fo.tzname(dt), "Three")
97 self.assertEqual(fo.dst(dt), timedelta(minutes=42))
503 dt = date(2000, 1, 2)
509 dt2 = dt + delta
510 self.assertEqual(dt2, dt + days)
512 dt2 = delta + dt
513 self.assertEqual(dt2, dt + days)
515 dt2 = dt - delta
516 self.assertEqual(dt2, dt - days)
522 dt2 = dt + delta
523 self.assertEqual(dt2, dt + days)
525 dt2 = delta + dt
526 self.assertEqual(dt2, dt + days)
528 dt2 = dt - delta
529 self.assertEqual(dt2, dt - days)
541 dt = self.theclass(2002, 3, 1)
542 self.assertEqual(dt.year, 2002)
543 self.assertEqual(dt.month, 3)
544 self.assertEqual(dt.day, 1)
547 for dt in (self.theclass(1, 2, 3),
549 # Verify dt -> string -> date identity.
550 s = repr(dt)
554 self.assertEqual(dt, dt2)
557 dt2 = self.theclass(dt.year, dt.month, dt.day)
558 self.assertEqual(dt, dt2)
731 dt = self.theclass.min + delta
732 dt -= delta # no problem
733 self.assertRaises(OverflowError, dt.__sub__, delta)
734 self.assertRaises(OverflowError, dt.__add__, -delta)
736 dt = self.theclass.max - delta
737 dt += delta # no problem
738 self.assertRaises(OverflowError, dt.__add__, delta)
739 self.assertRaises(OverflowError, dt.__sub__, -delta)
897 dt = self.theclass(2007, 9, 10)
898 self.assertEqual(dt.__format__(''), str(dt))
912 self.assertEqual(b.__format__(''), str(dt))
918 self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
919 self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
1153 dt = self.theclass(2002, 3, 1, 12, 0)
1154 self.assertEqual(dt.year, 2002)
1155 self.assertEqual(dt.month, 3)
1156 self.assertEqual(dt.day, 1)
1157 self.assertEqual(dt.hour, 12)
1158 self.assertEqual(dt.minute, 0)
1159 self.assertEqual(dt.second, 0)
1160 self.assertEqual(dt.microsecond, 0)
1165 dt = self.theclass(2002, 3, 1, 12, 59, 59, 8000)
1166 self.assertEqual(dt.year, 2002)
1167 self.assertEqual(dt.month, 3)
1168 self.assertEqual(dt.day, 1)
1169 self.assertEqual(dt.hour, 12)
1170 self.assertEqual(dt.minute, 59)
1171 self.assertEqual(dt.second, 59)
1172 self.assertEqual(dt.microsecond, 8000)
1175 for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7),
1177 # Verify dt -> string -> datetime identity.
1178 s = repr(dt)
1182 self.assertEqual(dt, dt2)
1185 dt2 = self.theclass(dt.year, dt.month, dt.day,
1186 dt.hour, dt.minute, dt.second,
1187 dt.microsecond)
1188 self.assertEqual(dt, dt2)
1207 dt = self.theclass(2007, 9, 10, 4, 5, 1, 123)
1208 self.assertEqual(dt.__format__(''), str(dt))
1222 self.assertEqual(b.__format__(''), str(dt))
1228 self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
1229 self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
1269 def tzname(self, dt):
1585 dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
1586 self.assertEqual(dt.date(), date(2002, 3, 4))
1587 self.assertEqual(dt.time(), time(18, 45, 3, 1234))
1594 dt = combine(d, t)
1595 self.assertEqual(dt, expected)
1597 dt = combine(time=t, date=d)
1598 self.assertEqual(dt, expected)
1600 self.assertEqual(d, dt.date())
1601 self.assertEqual(t, dt.time())
1602 self.assertEqual(dt, combine(dt.date(), dt.time()))
1638 dt = self.theclass.now()
1640 self.assertRaises(TypeError, dt.astimezone) # not enough args
1641 self.assertRaises(TypeError, dt.astimezone, f, f) # too many args
1642 self.assertRaises(TypeError, dt.astimezone, dt) # arg wrong type
1643 self.assertRaises(ValueError, dt.astimezone, f) # naive
1644 self.assertRaises(ValueError, dt.astimezone, tz=f) # naive
1647 def utcoffset(self, dt): return None
1648 def dst(self, dt): return timedelta(0)
1650 self.assertRaises(ValueError, dt.astimezone, bog) # naive
1653 def utcoffset(self, dt): return timedelta(0)
1654 def dst(self, dt
1656 self.assertRaises(ValueError, dt.astimezone, alsobog) # also naive
2001 def tzname(self, dt): return dt and "real" or "none"
2002 def utcoffset(self, dt):
2003 return timedelta(minutes = dt and 42 or -42)
2021 def utcoffset(self, dt): pass
2026 def utcoffset(self, dt): pass
2035 def utcoffset(self, dt):
2062 def utcoffset(self, dt): return None
2063 def dst(self, dt): return None
2064 def tzname(self, dt): return None
2073 def utcoffset(self, dt): return timedelta(minutes=-1439)
2074 def dst(self, dt): return timedelta(minutes=1439)
2075 def tzname(self, dt): return "aname"
2083 def utcoffset(self, dt): return "aname"
2084 def dst(self, dt): return 7
2085 def tzname(self, dt): return 0
2093 def utcoffset(self, dt): return timedelta(hours=-24)
2094 def dst(self, dt): return timedelta(hours=24)
2101 def utcoffset(self, dt): return timedelta(seconds=61)
2102 def dst(self, dt): return timedelta(microseconds=-81)
2242 def tzname(self, dt): return 42
2407 dt = self.theclass(1, 2, 3, 4, 5, 6, 7)
2408 self.assertEqual(dt.year, 1)
2409 self.assertEqual(dt.month, 2)
2410 self.assertEqual(dt.day, 3)
2411 self.assertEqual(dt.hour, 4)
2412 self.assertEqual(dt.minute, 5)
2413 self.assertEqual(dt.second, 6)
2414 self.assertEqual(dt.microsecond, 7)
2415 self.assertEqual(dt.tzinfo, None)
2465 def utcoffset(self, dt): return None
2477 def utcoffset(self, dt):
2552 dt = datetime.combine(d, tz)
2553 self.assertEqual(dt, datetime(2002, 3, 4, 18, 45, 3, 1234,
2558 dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234, tzinfo=met)
2559 self.assertEqual(dt.date(), date(2002, 3, 4))
2560 self.assertEqual(dt.time(), time(18, 45, 3, 1234))
2561 self.assertEqual(dt.timetz(), time(18, 45, 3, 1234, tzinfo=met))
2726 def dst(self, dt):
2760 def dst(self, dt):
2772 def utcoffset(self, dt):
2883 dt = self.theclass.now(tz=f44m)
2884 self.assertTrue(dt.tzinfo is f44m)
2886 self.assertRaises(ValueError, dt.astimezone, fnone)
2888 self.assertRaises(TypeError, dt.astimezone, None)
2890 x = dt.astimezone(dt.tzinfo)
2892 dt.date())
2893 self.assertEqual(x.time(), dt.time())
2896 got = dt.astimezone(fm5h)
2899 expected = dt - dt.utcoffset() # in effect, convert to UTC
2900 expected += fm5h.utcoffset(dt) # and from there to local time
3010 def first_sunday_on_or_after(dt):
3011 days_to_go = 6 - dt.weekday()
3013 dt += timedelta(days_to_go)
3014 return dt
3038 def tzname(self, dt):
3039 if self.dst(dt):
3044 def utcoffset(self, dt):
3045 return self.stdoffset + self.dst(dt)
3047 def dst(self, dt):
3048 if dt is None or dt.tzinfo is None:
3052 assert dt.tzinfo is self
3055 start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
3059 end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
3063 # dt first.
3064 if start <= dt.replace(tzinfo=None) < end:
3086 def checkinside(self, dt, tz, utc, dston, dstoff):
3087 self.assertEqual(dt.dst(), HOUR)
3090 self.assertEqual(dt.astimezone(tz), dt)
3092 asutc = dt.astimezone(utc)
3103 if dt.date() == dston.date() and dt.hour == 2:
3106 self.assertEqual(there_and_back + HOUR, dt)
3112 dt.astimezone(utc))
3115 self.assertEqual(dt, there_and_back)
3127 if dt.date() == dstoff.date() and dt.hour == 0:
3130 self.assertEqual(nexthour_tz, dt.replace(hour=1))
3133 self.assertEqual(nexthour_tz, dt.replace(hour=1))
3135 self.assertEqual(nexthour_tz - dt, HOUR)
3138 def checkoutside(self, dt, tz, utc):
3139 self.assertEqual(dt.dst(), ZERO)
3142 self.assertEqual(dt.astimezone(tz), dt)
3145 asutc = dt.astimezone(utc)
3147 self.assertEqual(dt, there_and_back)
3248 def utcoffset(self, dt): return HOUR
3249 def dst(self, dt): return HOUR
3257 def dst(self, dt): return None
3272 def fromutc(self, dt):
3273 return dt