mirror of
https://github.com/toeverything/AFFiNE.git
synced 2025-01-03 05:58:50 +03:00
parent
d6ad7d566f
commit
5c1f78afd4
@ -396,4 +396,9 @@ describe('humanTime', () => {
|
||||
})
|
||||
).toBe('本月');
|
||||
});
|
||||
|
||||
test('invalid time', () => {
|
||||
createI18n();
|
||||
expect(i18nTime('foobar')).toBe('');
|
||||
});
|
||||
});
|
||||
|
@ -73,6 +73,10 @@ export function i18nTime(
|
||||
) {
|
||||
const i18n = options.i18n ?? I18n;
|
||||
time = dayjs(time);
|
||||
if (!time.isValid()) {
|
||||
return ''; // invalid time, return empty string
|
||||
}
|
||||
|
||||
const now = dayjs(options.now);
|
||||
|
||||
const defaultRelativeOption = {
|
||||
|
Loading…
Reference in New Issue
Block a user