MCPcopy Index your code
hub / github.com/Lobos/react-ui / getWeekArray

Function getWeekArray

src/utils/datetime.js:50–77  ·  view source on GitHub ↗
(d)

Source from the content-addressed store, hash-verified

48}
49
50export function getWeekArray (d) {
51 let dayArray = [];
52 let daysInMonth = getDaysInMonth(d);
53 let daysInWeek;
54 let emptyDays;
55 let firstDayOfWeek;
56 let week;
57 let weekArray = [];
58
59 for (let i = 1; i <= daysInMonth; i++) {
60 dayArray.push(new Date(d.getFullYear(), d.getMonth(), i));
61 }
62
63 while (dayArray.length) {
64 firstDayOfWeek = dayArray[0].getDay();
65 daysInWeek = 7 - firstDayOfWeek;
66 emptyDays = 7 - daysInWeek;
67 week = dayArray.splice(0, daysInWeek);
68
69 for (let j = 0; j < emptyDays; j++) {
70 week.unshift(null);
71 }
72
73 weekArray.push(week);
74 }
75
76 return weekArray;
77}
78
79export function isEqualDate (d1, d2) {
80 if (!d1 || !d2 || !(d1 instanceof Date) || !(d2 instanceof Date)) {

Callers

nothing calls this directly

Calls 1

getDaysInMonthFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…