(x: number | undefined | null, hasMs = false)
| 342 | }; |
| 343 | |
| 344 | export const unixTimeToStr = (x: number | undefined | null, hasMs = false) => { |
| 345 | if (x === undefined || x === null || Number.isNaN(x)) { |
| 346 | return undefined; |
| 347 | } |
| 348 | if (hasMs) { |
| 349 | // 1716712162574 => '2024-05-26T16:29:22.574+08:00' |
| 350 | return window.moment(x).toISOString(true); |
| 351 | } else { |
| 352 | // 1716712162574 => '2024-05-26T16:29:22+08:00' |
| 353 | return window.moment(x).format() as string; |
| 354 | } |
| 355 | }; |
| 356 | |
| 357 | /** |
| 358 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cyclic_object_value#examples |
no outgoing calls
no test coverage detected