MCPcopy Create free account
hub / github.com/node-modules/utility / logDate

Function logDate

src/date.ts:81–100  ·  view source on GitHub ↗
(d?: Date | string | null, msSep?: string)

Source from the content-addressed store, hash-verified

79export function logDate(d?: Date): string;
80export function logDate(d?: Date | null, msSep?: string): string;
81export function logDate(d?: Date | string | null, msSep?: string): string {
82 if (typeof d === 'string') {
83 // logDate(msSep)
84 msSep = d;
85 d = new Date();
86 } else {
87 // logDate(d, msSep)
88 d = d || new Date();
89 }
90 const [ year, month, date, hours, minutes, seconds ] = getDateStringParts(d);
91 const millisecondsNum = d.getMilliseconds();
92 let milliseconds = `${millisecondsNum}`;
93 if (millisecondsNum < 10) {
94 milliseconds = `00${millisecondsNum}`;
95 } else if (millisecondsNum < 100) {
96 milliseconds = `0${millisecondsNum}`;
97 }
98 msSep = msSep || '.';
99 return `${year}-${month}-${date} ${hours}:${minutes}:${seconds}${msSep}${milliseconds}`;
100}
101
102export const YYYYMMDDHHmmssSSS = logDate;
103

Callers 2

date.test.tsFile · 0.85
getDateFromMillisecondsFunction · 0.85

Calls 1

getDateStringPartsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…