Lines Matching defs:time
1 """Test date/time type.
30 from datetime import time
34 import time as _time
88 'datetime_CAPI', 'time', 'timedelta', 'timezone',
232 """Simple time zone which pretends to always be in summer time, since
441 # Base class for testing a particular aspect of timedelta, time, date and
1175 a = self.theclass(a.year, a.month, a.day) # get rid of time parts
1187 a = self.theclass(a.year, a.month, a.day) # get rid of time parts
1310 import time
1314 ts = time.mktime((year, month, day, 0, 0, 0, 0, 0, -1))
1330 import time
1332 # We claim that today() is like fromtimestamp(time.time()), so
1336 ts = time.time()
1342 # time() calls.
1343 # 2. The platform time() has such fine resolution that we'll
1345 # 3. The platform time() has poor resolution, and we just
1350 time.sleep(0.1)
1497 # time.strftime.
1502 self.skipTest('time module does not support trailing %')
1761 # Timestamp depends on time zone, so we'll calculate the equivalent here
1762 ts = datetime.combine(base_d, time(0)).timestamp()
1804 # The constructor doesn't want to burn the time to validate all
2146 import time
2154 # self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
2158 self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
2420 import time
2422 ts = time.time()
2423 expected = time.localtime(ts)
2428 import time
2430 ts = time.time()
2431 expected = time.gmtime(ts)
2644 import time
2651 from_timestamp = self.theclass.utcfromtimestamp(time.time())
2791 self.assertEqual(dt.time(), time(18, 45, 3, 1234))
2795 t = time(18, 45, 3, 1234)
2801 dt = combine(time=t, date=d)
2805 self.assertEqual(t, dt.time())
2806 self.assertEqual(dt, combine(dt.date(), dt.time()))
2813 self.assertRaises(TypeError, combine, "date", "time") # wrong types
2814 self.assertRaises(TypeError, combine, d, "time") # wrong type
2822 t = time()
2825 self.assertEqual(dt.time(), t)
2929 # Timestamp depends on time zone, so we'll calculate the equivalent here
2940 ('combine', (date(*args[0:3]), time(*args[3:])), base_d),
3063 # Test strings like 2018-01-31+12:15 (where +12:15 is not a time zone)
3243 '2009-04-19T03;15:45', # Bad first time separator
3244 '2009-04-19T03:15;45', # Bad second time separator
3245 '2009-04-19T03:15:4500:00', # Bad time zone separator
3246 '2009-04-19T03:15:45.123456+24:30', # Invalid time zone offset
3250 '2009-04-10T12\ud80015', # Surrogate char in time
3254 '2009-04-19T12:', # Ends with time separator
3255 '2009-04-19T12:30:', # Ends with time separator
3256 '2009-04-19T12:30:45.', # Ends with time separator
3303 class SubclassTime(time):
3308 theclass = time
3329 # Verify t -> string -> time identity.
3622 # time is always True.
3701 # must be legit (which is true for time and datetime).
3706 # A datetime passes itself on, a time passes None.
3715 expected = cls is time and "none" or "real"
3718 expected = timedelta(minutes=(cls is time and -42 or 42))
3750 if cls is time:
3840 # Note that a time can't actually have an operand-dependent offset,
3841 # though (and time.utcoffset() passes None to tzinfo.utcoffset()),
3842 # so skip this test for time.
3843 if cls is not time:
3862 # Testing time objects with a non-None tzinfo.
3864 theclass = time
3878 t1 = time( 7, 47, tzinfo=est)
3879 t2 = time(12, 47, tzinfo=utc)
3880 t3 = time(13, 47, tzinfo=met)
3881 t4 = time(microsecond=40)
3882 t5 = time(microsecond=40, tzinfo=utc)
3931 d = 'datetime.time'
3944 t1 = time(23, 59, tzinfo=yuck)
3952 t = time(2, 3, 4, tzinfo=Badtzname())
3962 # Offsets that overflow a basic time.
4028 # time is always True.
4093 # In time w/ identical tzinfo objects, utcoffset is ignored.
4273 '12:30:45.123456+24:30', # Invalid time zone offset
4279 '12:30:45a', # Extra at tend of basic time
4280 '12:30:45.123a', # Extra at end of millisecond time
4281 '12:30:45.123456a', # Extra at end of microsecond time
4282 '12:30:45.123456-', # Extra at end of microsecond time
4283 '12:30:45.123456+', # Extra at end of microsecond time
4284 '12:30:45.123456+12:00:30a', # Extra at end of full time
4529 tz = time(18, 45, 3, 1234, tzinfo=met)
4538 self.assertEqual(dt.time(), time(18, 45, 3, 1234))
4539 self.assertEqual(dt.timetz(), time(18, 45, 3, 1234, tzinfo=met))
4544 timeaware = now.time().replace(tzinfo=tz55)
4624 # We don't know which time zone we're in, and don't have a tzinfo
4644 import time
4646 ts = time.time()
4670 # any idea here what time that actually is, we can only test that
4689 import time
4691 ts = time.time()
4770 # is never in effect for a UTC time.
4890 self.assertEqual(x.time(), dt.time())
4897 expected += fm5h.utcoffset(dt) # and from there to local time
4900 self.assertEqual(got.time(), expected.time())
5044 # In the US, DST starts at 2am (standard time) on the first Sunday in April.
5046 # and ends at 2am (DST time; 1am standard time) on the last Sunday of Oct,
5048 # being standard time on that day, there is no spelling in local time of
5049 # the last hour of DST (that's 1:MM DST, but 1:MM is taken as standard time).
5104 # The DST switch times for 2002, in std time.
5110 # Check a time that's inside DST.
5121 # because there are redundant spellings (in local time) of
5122 # UTC time when DST begins: the clock jumps from 1:59:59
5123 # to 3:00:00, and a local time of 2:MM:SS doesn't really
5125 # daylight time then (it's "after 2am"), really an alias
5126 # for 1:MM:SS standard time. The latter form is what
5130 # UTC gives the 1:MM:SS standard-time spelling.
5133 # time, there_and_back is not.
5144 # local time. When DST ends, the clock jumps from 1:59 back to 1:00
5146 # standard time. 1:MM DST == 0:MM EST, but 0:MM is taken to be
5147 # daylight time. The hour 1:MM daylight == 0:MM standard can't be
5148 # expressed in local time. Nevertheless, we want conversion back
5162 # Check a time that's outside DST.
5176 # Because 1:MM on the day DST ends is taken as being standard time,
5177 # there is no spelling in tz for the last hour of daylight time.
5179 # taken as being daylight time (and 1:MM is taken as being standard
5180 # time).
5211 # For these adjacent DST-aware time zones, the range of time offsets
5228 # time", so its offset is returned as -5, and -5 - -9 = 4. Adding 4
5229 # to 22:00 lands on 2:00, which makes no sense in local time (the
5308 # Always converts UTC to standard time.
5368 as_datetime = datetime.combine(as_date, time())
5403 time(),
5442 "datetime in UTC -> datetime in local time."
5469 raise ValueError("No suitable local time found")
5641 t = time(0, fold=1)
5646 time(0, 0, 0, 0, None, 0)
5650 t = dt.time()
5656 t = time(0)
5679 t = time(0)
5685 t = time(0)
5752 t = time(fold=1)
5762 t = time(fold=1)
5764 self.assertEqual(repr(t), 'datetime.time(0, 0, fold=1)')
5778 # Pick local time in the fold.
5786 # Pick local time in the gap.
5828 # .. or gets into the local fold after a standard time adjustment
5944 """datetime in UTC -> datetime in local time."""
6152 # Create a local time inside the gap
6164 hasattr(time, "tzset"), "time module has no attribute tzset"
6171 # tz data can represent solar time only with some difficulty and error.
6173 # civil time was generally not solar time in those years.
6197 # Create local time inside the gap
6320 class TimeSubclass(time):
6323 for klass in [time, TimeSubclass]:
6381 timedelta(1), timezone.utc, time(12, 00)]
6388 class TimeSubclass(time):
6391 t = time(12, 30)
6545 exp_time = time(22, 12, 55, 99999)
6559 exp_time = time(22, 12, 55, 99999)