Skip to content

Commit

Permalink
feat: "today" when using date filter, fixes #193
Browse files Browse the repository at this point in the history
  • Loading branch information
harttle committed Feb 20, 2020
1 parent 5cd42f4 commit 185312d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/builtin/filters/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isString, isNumber } from '../../util/underscore'
export default {
'date': (v: string | Date, arg: string) => {
let date = v
if (v === 'now') {
if (v === 'now' || v === 'today') {
date = new Date()
} else if (isNumber(v)) {
date = new Date(v * 1000)
Expand Down
3 changes: 3 additions & 0 deletions test/integration/builtin/filters/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ describe('filters/date', function () {
it('should create a new Date when given "now"', function () {
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 () {
return test('{{ "1991-02-22T00:00:00" | date: "%Y"}}', '1991')
})
Expand Down

0 comments on commit 185312d

Please sign in to comment.