@@ -80,19 +80,23 @@ describe('filters/date', function () {
80
80
return test ( '{{ "1991-02-22T00:00:00" | date: "%Y-%m-%dT%H:%M:%S"}}' , '1991-02-22T00:00:00' )
81
81
} )
82
82
describe ( 'when preserveTimezones is enabled' , function ( ) {
83
- const opts : LiquidOptions = { preserveTimezones : true }
83
+ const opts : LiquidOptions = { preserveTimezones : true , locale : 'en-US' }
84
84
85
85
it ( 'should not change the timezone between input and output' , function ( ) {
86
86
return test ( '{{ "1990-12-31T23:00:00Z" | date: "%Y-%m-%dT%H:%M:%S"}}' , '1990-12-31T23:00:00' , undefined , opts )
87
87
} )
88
88
it ( 'should apply numeric timezone offset (0)' , function ( ) {
89
- return test ( '{{ "1990-12-31T23:00:00+00:00" | date: "%Y-%m-%dT%H:%M:%S"}}' , '1990-12-31T23:00:00' , undefined , opts )
89
+ return test ( '{{ "1990-12-31T23:00:00+00:00" | date: "%Y-%m-%dT%H:%M:%S %z "}}' , '1990-12-31T23:00:00 +0000 ' , undefined , opts )
90
90
} )
91
91
it ( 'should apply numeric timezone offset (-1)' , function ( ) {
92
- return test ( '{{ "1990-12-31T23:00:00-01:00" | date: "%Y-%m-%dT%H:%M:%S"}}' , '1990-12-31T23:00:00' , undefined , opts )
92
+ return test ( '{{ "1990-12-31T23:00:00-01:00" | date: "%Y-%m-%dT%H:%M:%S %z "}}' , '1990-12-31T23:00:00 -0100 ' , undefined , opts )
93
93
} )
94
94
it ( 'should apply numeric timezone offset (+2.30)' , function ( ) {
95
- return test ( '{{ "1990-12-31T23:00:00+02:30" | date: "%Y-%m-%dT%H:%M:%S"}}' , '1990-12-31T23:00:00' , undefined , opts )
95
+ return test ( '{{ "1990-12-31T23:00:00+02:30" | date: "%Y-%m-%dT%H:%M:%S %z"}}' , '1990-12-31T23:00:00 +0230' , undefined , opts )
96
+ } )
97
+ it ( 'should support timezone in more casual JavaScript Date' , async ( ) => {
98
+ await test ( '{{ "2025-01-02 03:04:05 -0100" | date: "%Y-%m-%dT%H:%M:%S %z" }}' , '2025-01-02T03:04:05 -0100' , undefined , opts )
99
+ await test ( '{{ "2025-01-02 03:04:05 -0100" | date }}' , 'Thursday, January 2, 2025 at 3:04 am -0100' , undefined , opts )
96
100
} )
97
101
it ( 'should automatically work when timezone not specified' , function ( ) {
98
102
return test ( '{{ "1990-12-31T23:00:00" | date: "%Y-%m-%dT%H:%M:%S"}}' , '1990-12-31T23:00:00' , undefined , opts )
0 commit comments