• Home
  • Raw
  • Download

Lines Matching +full:to +full:- +full:regex +full:- +full:range

1 """Strptime-related classes and functions.
4 LocaleTime -- Discovers and stores locale-specific time information
5 TimeRE -- Creates regexes for pattern matching a string of text containing
9 _getlang -- Figure out what language is being used for the locale
10 strptime -- Calculates the time struct represented by the passed-in string
27 # Figure out what the current language is set to.
31 """Stores and handles locale-specific information related to time.
34 f_weekday -- full weekday names (7-item list)
35 a_weekday -- abbreviated weekday names (7-item list)
36 f_month -- full month names (13-item list; dummy value in [0], which
38 a_month -- abbreviated month names (13-item list, dummy value in
40 am_pm -- AM/PM representation (2-item list)
41 LC_date_time -- format string for date/time representation (string)
42 LC_date -- format string for date representation (string)
43 LC_time -- format string for time representation (string)
44 timezone -- daylight- and non-daylight-savings timezone representation
45 (2-item list of sets)
46 lang -- Language used by instance (2-item tuple)
55 exiting. This is to make sure that the attributes were not set with a
57 happen when using threads where one thread calls a locale-dependent
60 locks to prevent changing the locale while locale-dependent code is
83 a_weekday = [calendar.day_abbr[i].lower() for i in range(7)]
84 f_weekday = [calendar.day_name[i].lower() for i in range(7)]
90 a_month = [calendar.month_abbr[i].lower() for i in range(13)]
91 f_month = [calendar.month_name[i].lower() for i in range(13)]
99 # magical; just happened to have used it everywhere else where a
139 # If %W is used, then Sunday, 2005-01-03 will fall on week 0 since
140 # 2005-01-03 occurs before the first Monday of the year. Otherwise
171 """Handle conversion from format directives to regexes."""
185 # The " [1-9]" part of the regex is to make %c from ANSI C work
186 'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])",
187 'f': r"(?P<f>[0-9]{1,6})",
188 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)",
189 'I': r"(?P<I>1[0-2]|0[1-9]|[1-9])",
191 'j': r"(?P<j>36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])",
192 'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])",
193 'M': r"(?P<M>[0-5]\d|\d)",
194 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)",
195 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)",
196 'w': r"(?P<w>[0-6])",
197 'u': r"(?P<u>[1-7])",
198 'V': r"(?P<V>5[0-3]|0[1-9]|[1-4]\d|\d)",
201 #XXX: Does 'Y' need to worry about having less or more than
204 'z': r"(?P<z>[+-]\d\d:?[0-5]\d(:?[0-5]\d(\.\d{1,6})?)?|(?-i:Z))",
220 """Convert a list to a regex string for matching a directive.
222 Want possible matching values to be from longest to shortest. This
234 regex = '|'.join(re_escape(stuff) for stuff in to_convert)
235 regex = '(?P<%s>%s' % (directive, regex)
236 return '%s)' % regex
239 """Return regex pattern for the format string.
241 Need to make sure that any characters that might be interpreted as
242 regex syntax are escaped.
247 # as regex syntax. Cannot use re.escape since we have to deal with
256 format[:directive_index-1],
278 # easier to just shift the view to Sunday being the first day of the
283 # Need to watch out for a week 0 (when the first day of the year is not
285 week_0_length = (7 - first_weekday) % 7
287 return 1 + day_of_week - first_weekday
289 days_to_week = week_0_length + (7 * (week_of_year - 1))
296 ISO week days range from 1 (Monday) to 7 (Sunday).
299 ordinal = (iso_week * 7) + iso_weekday - correction
304 iso_year -= 1
305 ordinal -= datetime_date(iso_year, 1, 1).toordinal()
310 """Return a 2-tuple consisting of a time struct and an int containing
358 tz = -1
361 # Default to -1 to signify that values not known; not critical to have,
365 # weekday and julian defaulted to None so as to signal need to calculate
378 #value in the range of [00, 68] is in the century 2000, while
409 # We're in PM so we need to add 12 to the hour unless
420 # Pad to always return microseconds.
421 s += "0" * (6 - len(s))
432 weekday -= 1
435 weekday -= 1
465 # Pad to always return microseconds.
466 gmtoff_remainder_padding = "0" * (6 - len(gmtoff_remainder))
468 if z.startswith("-"):
469 gmtoff = -gmtoff
470 gmtoff_fraction = -gmtoff_fraction
472 # Since -1 is default value only need to worry about setting tz if
473 # it can be something other than -1.
478 # same and yet time.daylight is true; too ambiguous to
479 # be able to tell what timezone has daylight savings
525 year -= 1
530 # Cannot pre-calculate datetime_date() since can change in Julian
533 # Need to add 1 to result since first day of the year is 1, not 0.
534 julian = datetime_date(year, month, day).toordinal() - \
536 else: # Assume that if they bothered to include Julian day (or if it was
539 (julian - 1) +
551 # use the default of 1900 for computations. We set it back to ensure
569 tzname, gmtoff = tt[-2:]