Lines Matching defs:_strptime
13 import _strptime
18 self.assertEqual(_strptime._getlang(), locale.getlocale(locale.LC_TIME))
21 """Tests for _strptime.LocaleTime.
31 self.LT_ins = _strptime.LocaleTime()
102 LT = _strptime.LocaleTime()
110 self.assertEqual(self.LT_ins.lang, _strptime._getlang())
118 self.time_re = _strptime.TimeRE()
119 self.locale_time = _strptime.LocaleTime()
172 test_locale = _strptime.LocaleTime()
174 self.assertEqual(_strptime.TimeRE(test_locale).pattern("%Z"), '',
187 locale_time = _strptime.LocaleTime()
191 time_re = _strptime.TimeRE(locale_time)
206 """Tests for _strptime.strptime."""
214 self.assertRaises(ValueError, _strptime._strptime_time, data_string="%d",
218 _strptime._strptime_time("2005", bad_format)
231 _strptime._strptime("1999 50", "%Y %V")
234 _strptime._strptime("1999 51", "%G %V")
238 _strptime._strptime("1999 51","%G %{}".format(w))
241 _strptime._strptime("2015", "%G")
244 _strptime._strptime("1999 256", "%G %j")
250 _strptime._strptime_time('', '%D')
254 _strptime._strptime_time('19', '%Y %')
259 self.assertRaises(ValueError, _strptime._strptime_time, "10 12", "%m")
264 strp_output = _strptime._strptime_time(strf_output, "%" + directive)
277 strp_output = _strptime._strptime_time(bound, '%y')
296 strp_output = _strptime._strptime_time(strf_output, "%I %p")
313 tup, frac, _ = _strptime._strptime(str(d), format="%Y-%m-%d %H:%M:%S.%f")
329 (*_, offset), _, offset_fraction = _strptime._strptime("+0130", "%z")
332 (*_, offset), _, offset_fraction = _strptime._strptime("-0100", "%z")
335 (*_, offset), _, offset_fraction = _strptime._strptime("-013030", "%z")
338 (*_, offset), _, offset_fraction = _strptime._strptime("-013030.000001", "%z")
341 (*_, offset), _, offset_fraction = _strptime._strptime("+01:00", "%z")
344 (*_, offset), _, offset_fraction = _strptime._strptime("-01:30", "%z")
347 (*_, offset), _, offset_fraction = _strptime._strptime("-01:30:30", "%z")
350 (*_, offset), _, offset_fraction = _strptime._strptime("-01:30:30.000001", "%z")
353 (*_, offset), _, offset_fraction = _strptime._strptime("+01:30:30.001", "%z")
356 (*_, offset), _, offset_fraction = _strptime._strptime("Z", "%z")
362 _strptime._strptime("-01:30:30.", "%z")
364 _strptime._strptime("-0130:30", "%z")
366 _strptime._strptime("-01:30:30.1234567", "%z")
368 _strptime._strptime("-01:30:30:123456", "%z")
370 _strptime._strptime("-01:3030", "%z")
382 strp_output = _strptime._strptime_time("UTC", "%Z")
384 strp_output = _strptime._strptime_time("GMT", "%Z")
388 strp_output = _strptime._strptime_time(strf_output, "%Z")
389 locale_time = _strptime.LocaleTime()
414 tz_value = _strptime._strptime_time(tz_name, "%Z")[8]
438 strp_output = _strptime._strptime_time(strf_output, "%m %% %Y")
446 self.assertTrue(_strptime._strptime_time(strf_output.upper(), "%B"),
448 self.assertTrue(_strptime._strptime_time(strf_output.lower(), "%B"),
450 self.assertTrue(_strptime._strptime_time(strf_output.capitalize(), "%B"),
456 strp_output = _strptime._strptime_time('1', '%m')
468 self.assertTrue(_strptime._strptime_time(need_escaping, need_escaping))
479 """Test a _strptime regression in '%I %p' at 12 noon (12 PM)"""
485 eq(_strptime._strptime_time('12 PM', '%I %p')[3], 12)
486 eq(_strptime._strptime_time('12 AM', '%I %p')[3], 0)
490 """Test a _strptime regression that all julian (1-366) are accepted"""
496 eq(_strptime._strptime_time('%d 2004' % i, '%j %Y')[7], i)
508 result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
518 result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
533 result = _strptime._strptime_time(time.strftime(format_string, self.time_tuple),
566 strp_output = _strptime._strptime_time(strp_input,
600 self.assertEqual(_strptime._strptime_time(value, format)[:-1], expected)
652 _strptime._strptime_time("10", "%d")
653 _strptime._strptime_time("2005", "%Y")
654 _strptime._TimeRE_cache.locale_time.lang = "Ni"
655 original_time_re = _strptime._TimeRE_cache
656 _strptime._strptime_time("10", "%d")
657 self.assertIsNot(original_time_re, _strptime._TimeRE_cache)
658 self.assertEqual(len(_strptime._regex_cache), 1)
663 del _strptime._regex_cache['%d']
667 while len(_strptime._regex_cache) <= _strptime._CACHE_MAX_SIZE:
668 _strptime._regex_cache[bogus_key] = None
670 _strptime._strptime_time("10", "%d")
671 self.assertEqual(len(_strptime._regex_cache), 1)
676 locale_time_id = _strptime._TimeRE_cache.locale_time
677 _strptime._TimeRE_cache.locale_time.lang = "Ni"
678 _strptime._strptime_time("10", "%d")
679 self.assertIsNot(locale_time_id, _strptime._TimeRE_cache.locale_time)
689 _strptime._strptime_time('10', '%d')
691 first_time_re = _strptime._TimeRE_cache
695 _strptime._strptime_time('10', '%d')
697 second_time_re = _strptime._TimeRE_cache
714 tm = _strptime._strptime_time(time.tzname[0], '%Z')
716 tm = _strptime._strptime_time(time.tzname[1], '%Z')
719 first_time_re = _strptime._TimeRE_cache
723 tm = _strptime._strptime_time(time.tzname[0], '%Z')
725 tm = _strptime._strptime_time(time.tzname[1], '%Z')
728 second_time_re = _strptime._TimeRE_cache
733 _strptime._strptime_time(oldtzname[0], '%Z')
735 _strptime._strptime_time(oldtzname[1], '%Z')