MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / _parse

Method _parse

site-packages/dateutil/parser/_parser.py:668–875  ·  view source on GitHub ↗

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

(self, timestr, dayfirst=None, yearfirst=None, fuzzy=False,
               fuzzy_with_tokens=False)

Source from the content-addressed store, hash-verified

666 "tzname", "tzoffset", "ampm","any_unused_tokens"]
667
668 def _parse(self, timestr, dayfirst=None, yearfirst=None, fuzzy=False,
669 fuzzy_with_tokens=False):
670 """
671 Private method which performs the heavy lifting of parsing, called from
672 ``parse()``, which passes on its ``kwargs`` to this function.
673
674 :param timestr:
675 The string to parse.
676
677 :param dayfirst:
678 Whether to interpret the first value in an ambiguous 3-integer date
679 (e.g. 01/05/09) as the day (``True``) or month (``False``). If
680 ``yearfirst`` is set to ``True``, this distinguishes between YDM
681 and YMD. If set to ``None``, this value is retrieved from the
682 current :class:`parserinfo` object (which itself defaults to
683 ``False``).
684
685 :param yearfirst:
686 Whether to interpret the first value in an ambiguous 3-integer date
687 (e.g. 01/05/09) as the year. If ``True``, the first number is taken
688 to be the year, otherwise the last number is taken to be the year.
689 If this is set to ``None``, the value is retrieved from the current
690 :class:`parserinfo` object (which itself defaults to ``False``).
691
692 :param fuzzy:
693 Whether to allow fuzzy parsing, allowing for string like "Today is
694 January 1, 2047 at 8:21:00AM".
695
696 :param fuzzy_with_tokens:
697 If ``True``, ``fuzzy`` is automatically set to True, and the parser
698 will return a tuple where the first element is the parsed
699 :class:`datetime.datetime` datetimestamp and the second element is
700 a tuple containing the portions of the string which were ignored:
701
702 .. doctest::
703
704 >>> from dateutil.parser import parse
705 >>> parse("Today is January 1, 2047 at 8:21:00AM", fuzzy_with_tokens=True)
706 (datetime.datetime(2047, 1, 1, 8, 21), (u'Today is ', u' ', u'at '))
707
708 """
709 if fuzzy_with_tokens:
710 fuzzy = True
711
712 info = self.info
713
714 if dayfirst is None:
715 dayfirst = info.dayfirst
716
717 if yearfirst is None:
718 yearfirst = info.yearfirst
719
720 res = self._result()
721 l = _timelex.split(timestr) # Splits the timestr into tokens
722
723 skipped_idxs = []
724
725 # year/month/day list

Callers 1

parseMethod · 0.95

Calls 15

_parse_numeric_tokenMethod · 0.95
_ampm_validMethod · 0.95
_adjust_ampmMethod · 0.95
_could_be_tznameMethod · 0.95
_recombine_skippedMethod · 0.95
_ymdClass · 0.85
weekdayMethod · 0.80
monthMethod · 0.80
pertainMethod · 0.80
isdigitMethod · 0.80
convertyearMethod · 0.80
ampmMethod · 0.80

Tested by

no test coverage detected