(config)
| 2732 | |
| 2733 | // date from string and format string |
| 2734 | function configFromStringAndFormat(config) { |
| 2735 | // TODO: Move this to another part of the creation flow to prevent circular deps |
| 2736 | if (config._f === hooks.ISO_8601) { |
| 2737 | configFromISO(config); |
| 2738 | return; |
| 2739 | } |
| 2740 | if (config._f === hooks.RFC_2822) { |
| 2741 | configFromRFC2822(config); |
| 2742 | return; |
| 2743 | } |
| 2744 | config._a = []; |
| 2745 | getParsingFlags(config).empty = true; |
| 2746 | |
| 2747 | // This array is used to make a Date, either with `new Date` or `Date.UTC` |
| 2748 | var string = '' + config._i, |
| 2749 | i, |
| 2750 | parsedInput, |
| 2751 | tokens, |
| 2752 | token, |
| 2753 | skipped, |
| 2754 | stringLength = string.length, |
| 2755 | totalParsedInputLength = 0, |
| 2756 | era; |
| 2757 | |
| 2758 | tokens = |
| 2759 | expandFormat(config._f, config._locale).match(formattingTokens) || []; |
| 2760 | |
| 2761 | for (i = 0; i < tokens.length; i++) { |
| 2762 | token = tokens[i]; |
| 2763 | parsedInput = (string.match(getParseRegexForToken(token, config)) || |
| 2764 | [])[0]; |
| 2765 | if (parsedInput) { |
| 2766 | skipped = string.substr(0, string.indexOf(parsedInput)); |
| 2767 | if (skipped.length > 0) { |
| 2768 | getParsingFlags(config).unusedInput.push(skipped); |
| 2769 | } |
| 2770 | string = string.slice( |
| 2771 | string.indexOf(parsedInput) + parsedInput.length |
| 2772 | ); |
| 2773 | totalParsedInputLength += parsedInput.length; |
| 2774 | } |
| 2775 | // don't parse if it's not a known token |
| 2776 | if (formatTokenFunctions[token]) { |
| 2777 | if (parsedInput) { |
| 2778 | getParsingFlags(config).empty = false; |
| 2779 | } else { |
| 2780 | getParsingFlags(config).unusedTokens.push(token); |
| 2781 | } |
| 2782 | addTimeToArrayFromToken(token, parsedInput, config); |
| 2783 | } else if (config._strict && !parsedInput) { |
| 2784 | getParsingFlags(config).unusedTokens.push(token); |
| 2785 | } |
| 2786 | } |
| 2787 | |
| 2788 | // add remaining unparsed input length to the string |
| 2789 | getParsingFlags(config).charsLeftOver = |
| 2790 | stringLength - totalParsedInputLength; |
| 2791 | if (string.length > 0) { |
no test coverage detected