(config)
| 2809 | |
| 2810 | // date from string and format string |
| 2811 | function configFromStringAndFormat(config) { |
| 2812 | // TODO: Move this to another part of the creation flow to prevent circular deps |
| 2813 | if (config._f === hooks.ISO_8601) { |
| 2814 | configFromISO(config); |
| 2815 | return; |
| 2816 | } |
| 2817 | if (config._f === hooks.RFC_2822) { |
| 2818 | configFromRFC2822(config); |
| 2819 | return; |
| 2820 | } |
| 2821 | config._a = []; |
| 2822 | getParsingFlags(config).empty = true; |
| 2823 | |
| 2824 | // This array is used to make a Date, either with `new Date` or `Date.UTC` |
| 2825 | var string = '' + config._i, |
| 2826 | i, |
| 2827 | parsedInput, |
| 2828 | tokens, |
| 2829 | token, |
| 2830 | skipped, |
| 2831 | stringLength = string.length, |
| 2832 | totalParsedInputLength = 0, |
| 2833 | era, |
| 2834 | tokenLen; |
| 2835 | |
| 2836 | tokens = |
| 2837 | expandFormat(config._f, config._locale).match(formattingTokens) || []; |
| 2838 | tokenLen = tokens.length; |
| 2839 | for (i = 0; i < tokenLen; i++) { |
| 2840 | token = tokens[i]; |
| 2841 | parsedInput = (string.match(getParseRegexForToken(token, config)) || |
| 2842 | [])[0]; |
| 2843 | if (parsedInput) { |
| 2844 | skipped = string.substr(0, string.indexOf(parsedInput)); |
| 2845 | if (skipped.length > 0) { |
| 2846 | getParsingFlags(config).unusedInput.push(skipped); |
| 2847 | } |
| 2848 | string = string.slice( |
| 2849 | string.indexOf(parsedInput) + parsedInput.length |
| 2850 | ); |
| 2851 | totalParsedInputLength += parsedInput.length; |
| 2852 | } |
| 2853 | // don't parse if it's not a known token |
| 2854 | if (formatTokenFunctions[token]) { |
| 2855 | if (parsedInput) { |
| 2856 | getParsingFlags(config).empty = false; |
| 2857 | } else { |
| 2858 | getParsingFlags(config).unusedTokens.push(token); |
| 2859 | } |
| 2860 | addTimeToArrayFromToken(token, parsedInput, config); |
| 2861 | } else if (config._strict && !parsedInput) { |
| 2862 | getParsingFlags(config).unusedTokens.push(token); |
| 2863 | } |
| 2864 | } |
| 2865 | |
| 2866 | // add remaining unparsed input length to the string |
| 2867 | getParsingFlags(config).charsLeftOver = |
| 2868 | stringLength - totalParsedInputLength; |
no test coverage detected
searching dependent graphs…