@beyonk/date-utils
Advanced tools
Comparing version 4.7.6 to 4.7.7
@@ -13,3 +13,7 @@ import dayjs from 'dayjs' | ||
} | ||
return Intl.DateTimeFormat(locale, config).format(date) | ||
try { | ||
return Intl.DateTimeFormat(locale, config).format(date) | ||
} catch (e) { | ||
return 'Invalid Date' | ||
} | ||
} | ||
@@ -16,0 +20,0 @@ |
import { expect } from '@hapi/code' | ||
import dayjs from 'dayjs' | ||
import { | ||
@@ -147,2 +148,12 @@ formatLongDate, | ||
}) | ||
context('Invalid date', () => { | ||
it('invalid dayjs', () => { | ||
expect(formatLongDate(dayjs(''))).to.equal('Invalid Date') | ||
}) | ||
it('invalid Date', () => { | ||
expect(formatLongDate(new Date('ABC'))).to.equal('Invalid Date') | ||
}) | ||
}) | ||
}) |
{ | ||
"name": "@beyonk/date-utils", | ||
"version": "4.7.6", | ||
"version": "4.7.7", | ||
"description": "Beyonk Date Utils", | ||
@@ -5,0 +5,0 @@ "author": "Antony Jones <aj@desirableobjects.co.uk>", |
Sorry, the diff of this file is not supported yet
45203
1486