class documentation

Undocumented

Method __init__ Undocumented
Method parse Parse the date/time string into a :class:`datetime.datetime` object.
Instance Variable info Undocumented
Class _result Undocumented
Method _adjust_ampm Undocumented
Method _ampm_valid For fuzzy parsing, 'a' or 'am' (both valid English words) may erroneously trigger the AM/PM flag. Deal with that here.
Method _assign_hms Undocumented
Method _assign_tzname Undocumented
Method _build_naive Undocumented
Method _build_tzaware Undocumented
Method _build_tzinfo Undocumented
Method _could_be_tzname Undocumented
Method _find_hms_idx Undocumented
Method _parse Private method which performs the heavy lifting of parsing, called from ``parse()``, which passes on its ``kwargs`` to this function.
Method _parse_hms Undocumented
Method _parse_min_sec Undocumented
Method _parse_numeric_token Undocumented
Method _parsems Parse a I[.F] seconds value into (seconds, microseconds).
Method _recombine_skipped >>> tokens = ["foo", " ", "bar", " ", "19June2000", "baz"] >>> skipped_idxs = [0, 1, 2, 5] >>> _recombine_skipped(tokens, skipped_idxs) ["foo bar", "baz"]
Method _to_decimal Undocumented
def __init__(self, info=None): (source)

Undocumented

def parse(self, timestr, default=None, ignoretz=False, tzinfos=None, **kwargs): (source)

Parse the date/time string into a :class:`datetime.datetime` object. :param timestr: Any date/time string using the supported formats. :param default: The default datetime object, if this is a datetime object and not ``None``, elements specified in ``timestr`` replace elements in the default object. :param ignoretz: If set ``True``, time zones in parsed strings are ignored and a naive :class:`datetime.datetime` object is returned. :param tzinfos: Additional time zone names / aliases which may be present in the string. This argument maps time zone names (and optionally offsets from those time zones) to time zones. This parameter can be a dictionary with timezone aliases mapping time zone names to time zones or a function taking two parameters (``tzname`` and ``tzoffset``) and returning a time zone. The timezones to which the names are mapped can be an integer offset from UTC in seconds or a :class:`tzinfo` object. .. doctest:: :options: +NORMALIZE_WHITESPACE >>> from dateutil.parser import parse >>> from dateutil.tz import gettz >>> tzinfos = {"BRST": -7200, "CST": gettz("America/Chicago")} >>> parse("2012-01-19 17:21:00 BRST", tzinfos=tzinfos) datetime.datetime(2012, 1, 19, 17, 21, tzinfo=tzoffset(u'BRST', -7200)) >>> parse("2012-01-19 17:21:00 CST", tzinfos=tzinfos) datetime.datetime(2012, 1, 19, 17, 21, tzinfo=tzfile('/usr/share/zoneinfo/America/Chicago')) This parameter is ignored if ``ignoretz`` is set. :param \*\*kwargs: Keyword arguments as passed to ``_parse()``. :return: Returns a :class:`datetime.datetime` object or, if the ``fuzzy_with_tokens`` option is ``True``, returns a tuple, the first element being a :class:`datetime.datetime` object, the second a tuple containing the fuzzy tokens. :raises ParserError: Raised for invalid or unknown string format, if the provided :class:`tzinfo` is not in a valid format, or if an invalid date would be created. :raises TypeError: Raised for non-string or character stream input. :raises OverflowError: Raised if the parsed date exceeds the largest valid C integer on your system.

info = (source)

Undocumented

def _adjust_ampm(self, hour, ampm): (source)

Undocumented

def _ampm_valid(self, hour, ampm, fuzzy): (source)

For fuzzy parsing, 'a' or 'am' (both valid English words) may erroneously trigger the AM/PM flag. Deal with that here.

def _assign_hms(self, res, value_repr, hms): (source)

Undocumented

def _assign_tzname(self, dt, tzname): (source)

Undocumented

def _build_naive(self, res, default): (source)

Undocumented

def _build_tzaware(self, naive, res, tzinfos): (source)

Undocumented

def _build_tzinfo(self, tzinfos, tzname, tzoffset): (source)

Undocumented

def _could_be_tzname(self, hour, tzname, tzoffset, token): (source)

Undocumented

def _find_hms_idx(self, idx, tokens, info, allow_jump): (source)

Undocumented

def _parse(self, timestr, dayfirst=None, yearfirst=None, fuzzy=False, fuzzy_with_tokens=False): (source)

Private method which performs the heavy lifting of parsing, called from ``parse()``, which passes on its ``kwargs`` to this function. :param timestr: The string to parse. :param dayfirst: Whether to interpret the first value in an ambiguous 3-integer date (e.g. 01/05/09) as the day (``True``) or month (``False``). If ``yearfirst`` is set to ``True``, this distinguishes between YDM and YMD. If set to ``None``, this value is retrieved from the current :class:`parserinfo` object (which itself defaults to ``False``). :param yearfirst: Whether to interpret the first value in an ambiguous 3-integer date (e.g. 01/05/09) as the year. If ``True``, the first number is taken to be the year, otherwise the last number is taken to be the year. If this is set to ``None``, the value is retrieved from the current :class:`parserinfo` object (which itself defaults to ``False``). :param fuzzy: Whether to allow fuzzy parsing, allowing for string like "Today is January 1, 2047 at 8:21:00AM". :param fuzzy_with_tokens: If ``True``, ``fuzzy`` is automatically set to True, and the parser will return a tuple where the first element is the parsed :class:`datetime.datetime` datetimestamp and the second element is a tuple containing the portions of the string which were ignored: .. doctest:: >>> from dateutil.parser import parse >>> parse("Today is January 1, 2047 at 8:21:00AM", fuzzy_with_tokens=True) (datetime.datetime(2047, 1, 1, 8, 21), (u'Today is ', u' ', u'at '))

def _parse_hms(self, idx, tokens, info, hms_idx): (source)

Undocumented

def _parse_min_sec(self, value): (source)

Undocumented

def _parse_numeric_token(self, tokens, idx, info, ymd, res, fuzzy): (source)

Undocumented

def _parsems(self, value): (source)

Parse a I[.F] seconds value into (seconds, microseconds).

def _recombine_skipped(self, tokens, skipped_idxs): (source)

>>> tokens = ["foo", " ", "bar", " ", "19June2000", "baz"] >>> skipped_idxs = [0, 1, 2, 5] >>> _recombine_skipped(tokens, skipped_idxs) ["foo bar", "baz"]

def _to_decimal(self, val): (source)

Undocumented