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