Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wyozi authored and harttle committed Dec 18, 2020
1 parent d70cd2a commit de32259
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/util/strftime.ts
Expand Up @@ -177,21 +177,21 @@ function format (d: Date, match: RegExpExecArray) {
export class TimezoneDate extends Date {
ISO8601_TIMEZONE_PATTERN = /([zZ]|([+-])(\d{2}):(\d{2}))$/;

inputTimezoneOffset: number = 0;
inputTimezoneOffset = 0;

constructor (public dateString: string) {
super(dateString)
const m = dateString.match(this.ISO8601_TIMEZONE_PATTERN)
if (m && m[1] === 'Z') {
this.inputTimezoneOffset = this.getTimezoneOffset()
} else if (m && m[2] && m[3] && m[4]) {
const [, , sign, hours, minutes] = m;
const [, , sign, hours, minutes] = m
const delta = (sign === '+' ? 1 : -1) * (parseInt(hours, 10) * 60 + parseInt(minutes, 10))
this.inputTimezoneOffset = this.getTimezoneOffset() + delta
}
}

getDisplayDate(): Date {
getDisplayDate (): Date {
return new Date((+this) + this.inputTimezoneOffset * 60 * 1000)
}
}
2 changes: 1 addition & 1 deletion test/integration/builtin/filters/date.ts
Expand Up @@ -16,7 +16,7 @@ describe('filters/date', function () {
return test('{{ "1991-02-22T00:00:00" | date: "%Y-%m-%dT%H:%M:%S"}}', '1991-02-22T00:00:00')
})
describe('when preserveTimezones is enabled', function () {
const opts: LiquidOptions = { preserveTimezones: true };
const opts: LiquidOptions = { preserveTimezones: true }

it('should not change the timezone between input and output', function () {
return test('{{ "1990-12-31T23:00:00Z" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T23:00:00', undefined, opts)
Expand Down

0 comments on commit de32259

Please sign in to comment.