(timestampMs: number)
| 98 | * @returns A sortable date string in yyyymmdd-hhmmss-ms format |
| 99 | */ |
| 100 | export 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 | } |
no outgoing calls
no test coverage detected