parent
f151065ad9
commit
5d4a854eb0
2 changed files with 23 additions and 2 deletions
@ -0,0 +1,18 @@ |
||||
class ExtendedDate extends Date { |
||||
toLocaleISOString(): string { |
||||
const localeDateParts: string[] = this.toLocaleDateString('en-US', { |
||||
year: 'numeric', |
||||
month: '2-digit', |
||||
day: '2-digit', |
||||
}).split('/', 3); |
||||
const localDate = `${localeDateParts[2]}-${localeDateParts[0]}-${localeDateParts[1]}`; |
||||
const localeTime: string = this.toLocaleTimeString('en-US', { |
||||
hour12: false, |
||||
}); |
||||
const timezoneOffset: number = (this.getTimezoneOffset() / 60) * -1; |
||||
|
||||
return `${localDate}T${localeTime}${timezoneOffset}`; |
||||
} |
||||
} |
||||
|
||||
export default ExtendedDate; |
Loading…
Reference in new issue