(config)
| 2925 | |
| 2926 | // date from string and array of format strings |
| 2927 | function configFromStringAndArray(config) { |
| 2928 | var tempConfig, |
| 2929 | bestMoment, |
| 2930 | scoreToBeat, |
| 2931 | i, |
| 2932 | currentScore, |
| 2933 | validFormatFound, |
| 2934 | bestFormatIsValid = false, |
| 2935 | configfLen = config._f.length; |
| 2936 | |
| 2937 | if (configfLen === 0) { |
| 2938 | getParsingFlags(config).invalidFormat = true; |
| 2939 | config._d = new Date(NaN); |
| 2940 | return; |
| 2941 | } |
| 2942 | |
| 2943 | for (i = 0; i < configfLen; i++) { |
| 2944 | currentScore = 0; |
| 2945 | validFormatFound = false; |
| 2946 | tempConfig = copyConfig({}, config); |
| 2947 | if (config._useUTC != null) { |
| 2948 | tempConfig._useUTC = config._useUTC; |
| 2949 | } |
| 2950 | tempConfig._f = config._f[i]; |
| 2951 | configFromStringAndFormat(tempConfig); |
| 2952 | |
| 2953 | if (isValid(tempConfig)) { |
| 2954 | validFormatFound = true; |
| 2955 | } |
| 2956 | |
| 2957 | // if there is any input that was not parsed add a penalty for that format |
| 2958 | currentScore += getParsingFlags(tempConfig).charsLeftOver; |
| 2959 | |
| 2960 | //or tokens |
| 2961 | currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; |
| 2962 | |
| 2963 | getParsingFlags(tempConfig).score = currentScore; |
| 2964 | |
| 2965 | if (!bestFormatIsValid) { |
| 2966 | if ( |
| 2967 | scoreToBeat == null || |
| 2968 | currentScore < scoreToBeat || |
| 2969 | validFormatFound |
| 2970 | ) { |
| 2971 | scoreToBeat = currentScore; |
| 2972 | bestMoment = tempConfig; |
| 2973 | if (validFormatFound) { |
| 2974 | bestFormatIsValid = true; |
| 2975 | } |
| 2976 | } |
| 2977 | } else { |
| 2978 | if (currentScore < scoreToBeat) { |
| 2979 | scoreToBeat = currentScore; |
| 2980 | bestMoment = tempConfig; |
| 2981 | } |
| 2982 | } |
| 2983 | } |
| 2984 |
no test coverage detected
searching dependent graphs…