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