mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 14:28:51 +08:00
@@ -396,4 +396,9 @@ describe('humanTime', () => {
|
|||||||
})
|
})
|
||||||
).toBe('本月');
|
).toBe('本月');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('invalid time', () => {
|
||||||
|
createI18n();
|
||||||
|
expect(i18nTime('foobar')).toBe('');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ export function i18nTime(
|
|||||||
) {
|
) {
|
||||||
const i18n = options.i18n ?? I18n;
|
const i18n = options.i18n ?? I18n;
|
||||||
time = dayjs(time);
|
time = dayjs(time);
|
||||||
|
if (!time.isValid()) {
|
||||||
|
return ''; // invalid time, return empty string
|
||||||
|
}
|
||||||
|
|
||||||
const now = dayjs(options.now);
|
const now = dayjs(options.now);
|
||||||
|
|
||||||
const defaultRelativeOption = {
|
const defaultRelativeOption = {
|
||||||
|
|||||||
Reference in New Issue
Block a user