MCPcopy Create free account
hub / github.com/flyfloor/react-component / dateStr2Obj

Function dateStr2Obj

component/util/date.js:13–31  ·  view source on GitHub ↗
(dateStr, options={ begin: null, end: null})

Source from the content-addressed store, hash-verified

11};
12
13const dateStr2Obj = (dateStr, options={ begin: null, end: null}) => {
14 let begin = options.begin || BEGIN_DATE,
15 end = options.end;
16
17 let date = dateStr ? new Date(dateStr) : new Date();
18
19 begin = new Date(begin);
20 if (end) end = new Date(end);
21
22 let beginY = begin.getFullYear();
23 let endY;
24 if (end) endY = end.getFullYear();
25
26 if (beginY && endY && beginY > endY) begin = end;
27 if (begin.getFullYear() && date < begin) date = begin;
28 if (endY && date > end) date = end;
29
30 return date2Obj(date);
31};
32
33const date2DateStr = (date = new Date()) => {
34 let {year, month, day} = date2Obj(date);

Callers 3

initDateFunction · 0.50
renderDisplayFunction · 0.50
initDateFunction · 0.50

Calls 1

date2ObjFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…