mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
display logs in local time while retaining iso format
This commit is contained in:
committed by
Aiden McClelland
parent
a5c97d4c24
commit
c2f9c6a38d
@@ -36,4 +36,5 @@ export * from './types/workspace-config'
|
||||
|
||||
export * from './util/get-pkg-id'
|
||||
export * from './util/misc.util'
|
||||
export * from './util/to-local-iso-string'
|
||||
export * from './util/unused'
|
||||
|
||||
26
frontend/projects/shared/src/util/to-local-iso-string.ts
Normal file
26
frontend/projects/shared/src/util/to-local-iso-string.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export function toLocalIsoString(date: Date) {
|
||||
const tzo = -date.getTimezoneOffset()
|
||||
const dif = tzo >= 0 ? '+' : '-'
|
||||
|
||||
function pad(num: number) {
|
||||
return (num < 10 ? '0' : '') + num
|
||||
}
|
||||
|
||||
return (
|
||||
date.getFullYear() +
|
||||
'-' +
|
||||
pad(date.getMonth() + 1) +
|
||||
'-' +
|
||||
pad(date.getDate()) +
|
||||
'T' +
|
||||
pad(date.getHours()) +
|
||||
':' +
|
||||
pad(date.getMinutes()) +
|
||||
':' +
|
||||
pad(date.getSeconds()) +
|
||||
dif +
|
||||
pad(Math.floor(Math.abs(tzo) / 60)) +
|
||||
':' +
|
||||
pad(Math.abs(tzo) % 60)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user