MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / configFromISO

Function configFromISO

tests/test_code/js/moment/moment.js:2351–2405  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

2349
2350 // date from iso format
2351 function configFromISO(config) {
2352 var i,
2353 l,
2354 string = config._i,
2355 match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
2356 allowTime,
2357 dateFormat,
2358 timeFormat,
2359 tzFormat;
2360
2361 if (match) {
2362 getParsingFlags(config).iso = true;
2363
2364 for (i = 0, l = isoDates.length; i < l; i++) {
2365 if (isoDates[i][1].exec(match[1])) {
2366 dateFormat = isoDates[i][0];
2367 allowTime = isoDates[i][2] !== false;
2368 break;
2369 }
2370 }
2371 if (dateFormat == null) {
2372 config._isValid = false;
2373 return;
2374 }
2375 if (match[3]) {
2376 for (i = 0, l = isoTimes.length; i < l; i++) {
2377 if (isoTimes[i][1].exec(match[3])) {
2378 // match[2] should be 'T' or space
2379 timeFormat = (match[2] || ' ') + isoTimes[i][0];
2380 break;
2381 }
2382 }
2383 if (timeFormat == null) {
2384 config._isValid = false;
2385 return;
2386 }
2387 }
2388 if (!allowTime && timeFormat != null) {
2389 config._isValid = false;
2390 return;
2391 }
2392 if (match[4]) {
2393 if (tzRegex.exec(match[4])) {
2394 tzFormat = 'Z';
2395 } else {
2396 config._isValid = false;
2397 return;
2398 }
2399 }
2400 config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
2401 configFromStringAndFormat(config);
2402 } else {
2403 config._isValid = false;
2404 }
2405 }
2406
2407 function extractFromRFC2822Strings(
2408 yearStr,

Callers 2

configFromStringFunction · 0.85

Calls 2

getParsingFlagsFunction · 0.85

Tested by

no test coverage detected