mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
feat: add preserveTimezones option
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { LiquidOptions } from '../../../../src/liquid-options'
|
||||
import { test } from '../../../stub/render'
|
||||
|
||||
describe('filters/date', function () {
|
||||
@@ -14,17 +15,21 @@ describe('filters/date', function () {
|
||||
it('should parse as Date when given a timezoneless string', function () {
|
||||
return test('{{ "1991-02-22T00:00:00" | date: "%Y-%m-%dT%H:%M:%S"}}', '1991-02-22T00:00:00')
|
||||
})
|
||||
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')
|
||||
})
|
||||
it('should apply numeric timezone offset (0)', function () {
|
||||
return test('{{ "1990-12-31T23:00:00+00:00" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T23:00:00')
|
||||
})
|
||||
it('should apply numeric timezone offset (-1)', function () {
|
||||
return test('{{ "1990-12-31T23:00:00-01:00" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T23:00:00')
|
||||
})
|
||||
it('should apply numeric timezone offset (+2.30)', function () {
|
||||
return test('{{ "1990-12-31T23:00:00+02:30" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T23:00:00')
|
||||
describe('when preserveTimezones is enabled', function () {
|
||||
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)
|
||||
})
|
||||
it('should apply numeric timezone offset (0)', function () {
|
||||
return test('{{ "1990-12-31T23:00:00+00:00" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T23:00:00', undefined, opts)
|
||||
})
|
||||
it('should apply numeric timezone offset (-1)', function () {
|
||||
return test('{{ "1990-12-31T23:00:00-01:00" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T23:00:00', undefined, opts)
|
||||
})
|
||||
it('should apply numeric timezone offset (+2.30)', function () {
|
||||
return test('{{ "1990-12-31T23:00:00+02:30" | date: "%Y-%m-%dT%H:%M:%S"}}', '1990-12-31T23:00:00', undefined, opts)
|
||||
})
|
||||
})
|
||||
it('should render string as string if not valid', function () {
|
||||
return test('{{ "foo" | date: "%Y"}}', 'foo')
|
||||
|
||||
Reference in New Issue
Block a user