MCPcopy Create free account
hub / github.com/Rello/analytics / formatDate

Function formatDate

js/visualization.js:2225–2242  ·  view source on GitHub ↗
(date, orig)

Source from the content-addressed store, hash-verified

2223 };
2224
2225 const formatDate = (date, orig) => {
2226 if (isTimestamp) {
2227 if (tsLength > 10) return date.getTime().toString();
2228 return Math.floor(date.getTime() / 1000).toString();
2229 }
2230 if (parser) {
2231 return myMoment(date).format(parser);
2232 }
2233 if (typeof orig === 'string') {
2234 const len = orig.length;
2235 if (len === 10) return myMoment(date).format('YYYY-MM-DD');
2236 if (len === 16 && orig.includes('T')) return myMoment(date).format('YYYY-MM-DDTHH:mm');
2237 if (len === 16) return myMoment(date).format('YYYY-MM-DD HH:mm');
2238 if (len === 19 && orig.includes('T')) return myMoment(date).format('YYYY-MM-DDTHH:mm:ss');
2239 if (len === 19) return myMoment(date).format('YYYY-MM-DD HH:mm:ss');
2240 }
2241 return myMoment(date).format();
2242 };
2243
2244 const sums = {};
2245 const counts = {};

Callers 1

visualization.jsFile · 0.85

Calls 2

toStringMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected