mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
feat: "today" when using date filter, fixes #193
This commit is contained in:
@@ -4,7 +4,7 @@ import { isString, isNumber } from '../../util/underscore'
|
|||||||
export default {
|
export default {
|
||||||
'date': (v: string | Date, arg: string) => {
|
'date': (v: string | Date, arg: string) => {
|
||||||
let date = v
|
let date = v
|
||||||
if (v === 'now') {
|
if (v === 'now' || v === 'today') {
|
||||||
date = new Date()
|
date = new Date()
|
||||||
} else if (isNumber(v)) {
|
} else if (isNumber(v)) {
|
||||||
date = new Date(v * 1000)
|
date = new Date(v * 1000)
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ describe('filters/date', function () {
|
|||||||
it('should create a new Date when given "now"', function () {
|
it('should create a new Date when given "now"', function () {
|
||||||
return test('{{ "now" | date: "%Y"}}', (new Date()).getFullYear().toString())
|
return test('{{ "now" | date: "%Y"}}', (new Date()).getFullYear().toString())
|
||||||
})
|
})
|
||||||
|
it('should create a new Date when given "today"', function () {
|
||||||
|
return test('{{ "today" | date: "%Y"}}', (new Date()).getFullYear().toString())
|
||||||
|
})
|
||||||
it('should parse as Date when given UTC string', function () {
|
it('should parse as Date when given UTC string', function () {
|
||||||
return test('{{ "1991-02-22T00:00:00" | date: "%Y"}}', '1991')
|
return test('{{ "1991-02-22T00:00:00" | date: "%Y"}}', '1991')
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user