MCPcopy Index your code
hub / github.com/csev/py4e / configFromArray

Function configFromArray

code/gmane/Chart.bundle.js:2651–2711  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

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

Callers 3

configFromObjectFunction · 0.85
configFromInputFunction · 0.85

Calls 6

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

Tested by

no test coverage detected