Strptime

Classes

class badidatetime._strptime.DotDict(dictionary)[source]

Bases: dict

Allows dot notation access to dictionary attributes.

class badidatetime._strptime.LocaleTime[source]

Bases: object

Stores and handles locale-specific information related to time.

f_weekday -- full weekday names
Type:

7-item list

a_weekday -- abbreviated weekday names
Type:

7-item list

f_month -- full month names (13-item list; dummy value in [0], which

is added by code)

a_month -- abbreviated month names (13-item list, dummy value in

[0], which is added by code)

am_pm -- AM/PM representation
Type:

2-item list

LC_date_time -- format string for date/time representation
Type:

string

LC_date -- format string for date representation
Type:

string

LC_time -- format string for time representation
Type:

string

timezone -- daylight- and non-daylight-savings timezone representation

(2-item list of sets)

lang -- Language used by instance
Type:

2-item tuple

__calc_am_pm()

Set self.am_pm by using time.strftime().

The magic date (1, 1 , 1, hour, 0, 0, 0, 0, 0) is not really that magical, I just needed a time shortly after sunset and a time shortly before the next sunset.

__calc_date_time()
__calc_month()

Set self.f_month and self.a_month using the _timedateutils module.

__calc_timezone()
__calc_weekday()

Set self.a_weekday and self.f_weekday using the _timedateutils module.

class badidatetime._strptime.StrpTime(data_string, format='%a %b %d %H:%M:%S %Y')[source]

Bases: object

Return a 2-tuple consisting of a time struct and an int containing the number of microseconds based on the input string and the format string.

_check_iso_week(dot_dict)[source]
_clear_cache()[source]
_find_regex()[source]
_miscellaneous(dot_dict)[source]
_parse_found_dict(found, locale_time)[source]
start()[source]
class badidatetime._strptime.TimeRE(locale_time=None)[source]

Bases: dict

Handle conversion from format directives to regexes.

__seqToRE(to_convert, directive)

Convert a list to a regex string for matching a directive.

We want possible matching values to be from longest to shortest. This prevents the possibility of a match occurring for a value that also a sub-string of a larger value that should have matched (e.g., ‘abc’ matching when ‘abcdef’ should have been the match).

compile(format)[source]

Return a compiled re object for the format string.

pattern(format)[source]

Return regex pattern for the format string.

Need to make sure that any characters that might be interpreted as regex syntax are escaped.

badidatetime._strptime._calc_julian_from_U_or_W(year, week_of_year, day_of_week)[source]

Calculate the Julian day based on the year, week of the year, and day of the week, with week_start_day representing whether the week of the year assumes the week starts on Bahá (Saturday) 0. This means that both %U and %W would give the same results.

The week_of_year is NOT based on the ISO standard. If it’s the 1st day of the year then it is always week 0.

badidatetime._strptime._strptime_datetime(cls, data_string, format='%a %b %d %H:%M:%S %Y')[source]

Return a datetime class cls instance based on the input string and the format string. (cls will always be a datetime class object)

badidatetime._strptime._strptime_time(data_string, format='%a %b %d %H:%M:%S %Y')[source]

Return a time struct based on the input string and the format string.