mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-14 20:00:39 -07:00
fix: lint
This commit is contained in:
@@ -177,7 +177,7 @@ 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)
|
||||
@@ -185,13 +185,13 @@ export class TimezoneDate extends Date {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user