fix(localize): empty dates should be formatted as empty string
This commit is contained in:
parent
5255b1b77c
commit
6cfa301d1c
2 changed files with 3 additions and 3 deletions
|
|
@ -10,7 +10,7 @@ import { normalizeDate } from './normalizeDate.js';
|
||||||
*/
|
*/
|
||||||
export function formatDate(date, options) {
|
export function formatDate(date, options) {
|
||||||
if (!(date instanceof Date)) {
|
if (!(date instanceof Date)) {
|
||||||
return '0000-00-00';
|
return '';
|
||||||
}
|
}
|
||||||
const formatOptions = options || {};
|
const formatOptions = options || {};
|
||||||
// make sure months and days are always 2-digits
|
// make sure months and days are always 2-digits
|
||||||
|
|
|
||||||
|
|
@ -108,8 +108,8 @@ describe('formatDate', () => {
|
||||||
expect(formatDate(parsedDate, options)).to.equal('maandag 01 januari 1940');
|
expect(formatDate(parsedDate, options)).to.equal('maandag 01 januari 1940');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns a zero-date when input is not a Date object', async () => {
|
it('returns empty string when input is not a Date object', async () => {
|
||||||
const date = '1-1-2016';
|
const date = '1-1-2016';
|
||||||
expect(formatDate(date)).to.equal('0000-00-00');
|
expect(formatDate(date)).to.equal('');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue