mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
27 lines
521 B
TypeScript
27 lines
521 B
TypeScript
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)
|
|
)
|
|
}
|