Skip to content

Commit

Permalink
allow negative timestamps in relative [date] badge (#9321)
Browse files Browse the repository at this point in the history
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
  • Loading branch information
chris48s and repo-ranger[bot] authored Jun 26, 2023
1 parent c47f932 commit 53cce8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion services/date/date.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const documentation = `

export default class Date extends BaseService {
static category = 'other'
static route = { base: 'date', pattern: ':timestamp([0-9]+)' }
static route = { base: 'date', pattern: ':timestamp(-?[0-9]+)' }

static examples = [
{
Expand Down
4 changes: 4 additions & 0 deletions services/date/date.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ t.create('Relative date')
.get('/1540814400.json')
.expectBadge({ label: 'date', message: isRelativeFormattedDate })

t.create('Relative date (negative)')
.get('/-1.json')
.expectBadge({ label: 'date', message: isRelativeFormattedDate })

t.create('Relative date - Invalid')
.get('/9999999999999.json')
.expectBadge({ label: 'date', message: 'invalid date' })

0 comments on commit 53cce8f

Please sign in to comment.