MCPcopy
hub / github.com/react-dates/react-dates / isDayVisible

Function isDayVisible

src/utils/isDayVisible.js:13–56  ·  view source on GitHub ↗
(day, month, numberOfMonths, enableOutsideDays)

Source from the content-addressed store, hash-verified

11const endCacheInsideDays = new Map();
12
13export default function isDayVisible(day, month, numberOfMonths, enableOutsideDays) {
14 if (!moment.isMoment(day)) return false;
15
16 // Cloning is a little expensive, so we want to do it as little as possible.
17
18 const startKey = toISOMonthString(month);
19 // eslint-disable-next-line prefer-template
20 const endKey = startKey + '+' + numberOfMonths;
21
22 if (enableOutsideDays) {
23 if (!startCacheOutsideDays.has(startKey)) {
24 startCacheOutsideDays.set(startKey, month.clone().startOf('month').startOf('week'));
25 }
26
27 if (isBeforeDay(day, startCacheOutsideDays.get(startKey))) return false;
28
29 if (!endCacheOutsideDays.has(endKey)) {
30 endCacheOutsideDays.set(
31 endKey,
32 month.clone().endOf('week').add(numberOfMonths - 1, 'months').endOf('month')
33 .endOf('week'),
34 );
35 }
36
37 return !isAfterDay(day, endCacheOutsideDays.get(endKey));
38 }
39
40 // !enableOutsideDays
41
42 if (!startCacheInsideDays.has(startKey)) {
43 startCacheInsideDays.set(startKey, month.clone().startOf('month'));
44 }
45
46 if (isBeforeDay(day, startCacheInsideDays.get(startKey))) return false;
47
48 if (!endCacheInsideDays.has(endKey)) {
49 endCacheInsideDays.set(
50 endKey,
51 month.clone().add(numberOfMonths - 1, 'months').endOf('month'),
52 );
53 }
54
55 return !isAfterDay(day, endCacheInsideDays.get(endKey));
56}

Callers 7

getFocusedDayMethod · 0.85
addModifierFunction · 0.85
deleteModifierFunction · 0.85

Calls 3

toISOMonthStringFunction · 0.85
isBeforeDayFunction · 0.85
isAfterDayFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…