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

Function formatDate

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

Source from the content-addressed store, hash-verified

2894 };
2895
2896 const formatDate = (date, orig) => {
2897 if (isTimestamp) {
2898 if (tsLength > 10) return date.getTime().toString();
2899 return Math.floor(date.getTime() / 1000).toString();
2900 }
2901 if (parser) {
2902 return myMoment(date).format(parser);
2903 }
2904 if (typeof orig === 'string') {
2905 const len = orig.length;
2906 if (len === 10) return myMoment(date).format('YYYY-MM-DD');
2907 if (len === 16 && orig.includes('T')) return myMoment(date).format('YYYY-MM-DDTHH:mm');
2908 if (len === 16) return myMoment(date).format('YYYY-MM-DD HH:mm');
2909 if (len === 19 && orig.includes('T')) return myMoment(date).format('YYYY-MM-DDTHH:mm:ss');
2910 if (len === 19) return myMoment(date).format('YYYY-MM-DD HH:mm:ss');
2911 }
2912 return myMoment(date).format();
2913 };
2914
2915 const sums = {};
2916 const counts = {};

Callers 1

visualization.jsFile · 0.85

Calls 2

toStringMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected