MCPcopy Create free account
hub / github.com/code-pushup/cli / sortableReadableDateString

Function sortableReadableDateString

packages/utils/src/lib/process-id.ts:100–113  ·  view source on GitHub ↗
(timestampMs: number)

Source from the content-addressed store, hash-verified

98 * @returns A sortable date string in yyyymmdd-hhmmss-ms format
99 */
100export function sortableReadableDateString(timestampMs: number): string {
101 const date = new Date(timestampMs);
102 const MILLISECONDS_PER_SECOND = 1000;
103 const yyyy = date.getFullYear();
104 const mm = String(date.getMonth() + 1).padStart(2, '0');
105 const dd = String(date.getDate()).padStart(2, '0');
106 const hh = String(date.getHours()).padStart(2, '0');
107 const min = String(date.getMinutes()).padStart(2, '0');
108 const ss = String(date.getSeconds()).padStart(2, '0');
109 // eslint-disable-next-line @typescript-eslint/no-magic-numbers
110 const ms = String(timestampMs % MILLISECONDS_PER_SECOND).padStart(3, '0');
111
112 return `${yyyy}${mm}${dd}-${hh}${min}${ss}-${ms}`;
113}

Callers 2

getUniqueTimeIdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected