MCPcopy
hub / github.com/tdewolff/minify / configFromArray

Function configFromArray

_benchmarks/sample_moment.js:2654–2741  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

2652 // note: all values past the year are optional and will default to the lowest possible value.
2653 // [year, month, day , hour, minute, second, millisecond]
2654 function configFromArray(config) {
2655 var i,
2656 date,
2657 input = [],
2658 currentDate,
2659 expectedWeekday,
2660 yearToUse;
2661
2662 if (config._d) {
2663 return;
2664 }
2665
2666 currentDate = currentDateArray(config);
2667
2668 //compute day of the year from weeks and weekdays
2669 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
2670 dayOfYearFromWeekInfo(config);
2671 }
2672
2673 //if the day of the year is set, figure out what it is
2674 if (config._dayOfYear != null) {
2675 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
2676
2677 if (
2678 config._dayOfYear > daysInYear(yearToUse) ||
2679 config._dayOfYear === 0
2680 ) {
2681 getParsingFlags(config)._overflowDayOfYear = true;
2682 }
2683
2684 date = createUTCDate(yearToUse, 0, config._dayOfYear);
2685 config._a[MONTH] = date.getUTCMonth();
2686 config._a[DATE] = date.getUTCDate();
2687 }
2688
2689 // Default to current date.
2690 // * if no year, month, day of month are given, default to today
2691 // * if day of month is given, default month and year
2692 // * if month is given, default only year
2693 // * if year is given, don't default anything
2694 for (i = 0; i < 3 && config._a[i] == null; ++i) {
2695 config._a[i] = input[i] = currentDate[i];
2696 }
2697
2698 // Zero out whatever was not defaulted, including time
2699 for (; i < 7; i++) {
2700 config._a[i] = input[i] =
2701 config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i];
2702 }
2703
2704 // Check for 24:00:00.000
2705 if (
2706 config._a[HOUR] === 24 &&
2707 config._a[MINUTE] === 0 &&
2708 config._a[SECOND] === 0 &&
2709 config._a[MILLISECOND] === 0
2710 ) {
2711 config._nextDay = true;

Callers 3

configFromObjectFunction · 0.85
configFromInputFunction · 0.85

Calls 6

getParsingFlagsFunction · 0.85
createUTCDateFunction · 0.85
currentDateArrayFunction · 0.70
dayOfYearFromWeekInfoFunction · 0.70
defaultsFunction · 0.70
daysInYearFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…