(config)
| 2756 | |
| 2757 | // date from string and format string |
| 2758 | function configFromStringAndFormat(config) { |
| 2759 | // TODO: Move this to another part of the creation flow to prevent circular deps |
| 2760 | if (config._f === utils_hooks__hooks.ISO_8601) { |
| 2761 | configFromISO(config); |
| 2762 | return; |
| 2763 | } |
| 2764 | |
| 2765 | config._a = []; |
| 2766 | getParsingFlags(config).empty = true; |
| 2767 | |
| 2768 | // This array is used to make a Date, either with `new Date` or `Date.UTC` |
| 2769 | var string = '' + config._i, |
| 2770 | i, parsedInput, tokens, token, skipped, |
| 2771 | stringLength = string.length, |
| 2772 | totalParsedInputLength = 0; |
| 2773 | |
| 2774 | tokens = expandFormat(config._f, config._locale).match(formattingTokens) || []; |
| 2775 | |
| 2776 | for (i = 0; i < tokens.length; i++) { |
| 2777 | token = tokens[i]; |
| 2778 | parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0]; |
| 2779 | if (parsedInput) { |
| 2780 | skipped = string.substr(0, string.indexOf(parsedInput)); |
| 2781 | if (skipped.length > 0) { |
| 2782 | getParsingFlags(config).unusedInput.push(skipped); |
| 2783 | } |
| 2784 | string = string.slice(string.indexOf(parsedInput) + parsedInput.length); |
| 2785 | totalParsedInputLength += parsedInput.length; |
| 2786 | } |
| 2787 | // don't parse if it's not a known token |
| 2788 | if (formatTokenFunctions[token]) { |
| 2789 | if (parsedInput) { |
| 2790 | getParsingFlags(config).empty = false; |
| 2791 | } |
| 2792 | else { |
| 2793 | getParsingFlags(config).unusedTokens.push(token); |
| 2794 | } |
| 2795 | addTimeToArrayFromToken(token, parsedInput, config); |
| 2796 | } |
| 2797 | else if (config._strict && !parsedInput) { |
| 2798 | getParsingFlags(config).unusedTokens.push(token); |
| 2799 | } |
| 2800 | } |
| 2801 | |
| 2802 | // add remaining unparsed input length to the string |
| 2803 | getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength; |
| 2804 | if (string.length > 0) { |
| 2805 | getParsingFlags(config).unusedInput.push(string); |
| 2806 | } |
| 2807 | |
| 2808 | // clear _12h flag if hour is <= 12 |
| 2809 | if (getParsingFlags(config).bigHour === true && |
| 2810 | config._a[HOUR] <= 12 && |
| 2811 | config._a[HOUR] > 0) { |
| 2812 | getParsingFlags(config).bigHour = undefined; |
| 2813 | } |
| 2814 | // handle meridiem |
| 2815 | config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem); |
no test coverage detected