(self, tokens, idx, info, ymd, res, fuzzy)
| 867 | return res, None |
| 868 | |
| 869 | def _parse_numeric_token(self, tokens, idx, info, ymd, res, fuzzy): |
| 870 | # Token is a number |
| 871 | value_repr = tokens[idx] |
| 872 | try: |
| 873 | value = self._to_decimal(value_repr) |
| 874 | except Exception as e: |
| 875 | raise ValueError("Unknown numeric token") from e |
| 876 | |
| 877 | len_li = len(value_repr) |
| 878 | |
| 879 | len_l = len(tokens) |
| 880 | |
| 881 | if (len(ymd) == 3 and len_li in (2, 4) and |
| 882 | res.hour is None and |
| 883 | (idx + 1 >= len_l or |
| 884 | (tokens[idx + 1] != ':' and |
| 885 | info.hms(tokens[idx + 1]) is None))): |
| 886 | # 19990101T23[59] |
| 887 | s = tokens[idx] |
| 888 | res.hour = int(s[:2]) |
| 889 | |
| 890 | if len_li == 4: |
| 891 | res.minute = int(s[2:]) |
| 892 | |
| 893 | elif len_li == 6 or (len_li > 6 and tokens[idx].find('.') == 6): |
| 894 | # YYMMDD or HHMMSS[.ss] |
| 895 | s = tokens[idx] |
| 896 | |
| 897 | if not ymd and '.' not in tokens[idx]: |
| 898 | ymd.append(s[:2]) |
| 899 | ymd.append(s[2:4]) |
| 900 | ymd.append(s[4:]) |
| 901 | else: |
| 902 | # 19990101T235959[.59] |
| 903 | |
| 904 | # TODO: Check if res attributes already set. |
| 905 | res.hour = int(s[:2]) |
| 906 | res.minute = int(s[2:4]) |
| 907 | res.second, res.microsecond = self._parsems(s[4:]) |
| 908 | |
| 909 | elif len_li in (8, 12, 14): |
| 910 | # YYYYMMDD |
| 911 | s = tokens[idx] |
| 912 | ymd.append(s[:4], 'Y') |
| 913 | ymd.append(s[4:6]) |
| 914 | ymd.append(s[6:8]) |
| 915 | |
| 916 | if len_li > 8: |
| 917 | res.hour = int(s[8:10]) |
| 918 | res.minute = int(s[10:12]) |
| 919 | |
| 920 | if len_li > 12: |
| 921 | res.second = int(s[12:]) |
| 922 | |
| 923 | elif self._find_hms_idx(idx, tokens, info, allow_jump=True) is not None: |
| 924 | # HH[ ]h or MM[ ]m or SS[.ss][ ]s |
| 925 | hms_idx = self._find_hms_idx(idx, tokens, info, allow_jump=True) |
| 926 | (idx, hms) = self._parse_hms(idx, tokens, info, hms_idx) |
no test coverage detected