Skip to content

Commit

Permalink
fix: move offset adding complexity inside TimezoneDate
Browse files Browse the repository at this point in the history
  • Loading branch information
wyozi authored and harttle committed Dec 18, 2020
1 parent e3ecfe3 commit 26b2175
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/util/strftime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const formatCodes = {
export default function (inputDate: Date, formatStr: string) {
let d = inputDate
if (d instanceof TimezoneDate) {
d = new Date((+d) + d.inputTimezoneOffset * 60 * 1000)
d = d.getDisplayDate()
}

let output = ''
Expand Down Expand Up @@ -190,4 +190,8 @@ export class TimezoneDate extends Date {
this.inputTimezoneOffset = this.getTimezoneOffset() + delta
}
}

getDisplayDate(): Date {
return new Date((+this) + this.inputTimezoneOffset * 60 * 1000)
}
}

0 comments on commit 26b2175

Please sign in to comment.