File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
packages/ui/src/composables Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { computed, type ComputedRef } from 'vue'
22
33import { injectI18n } from '../providers/i18n'
44
5- export type Formatter = ( value : Date | number , options ?: FormatOptions ) => string
5+ export type Formatter = ( value : Date | number | null | undefined , options ?: FormatOptions ) => string
66
77export interface FormatOptions {
88 roundingMode ?: 'halfExpand' | 'floor' | 'ceil'
@@ -25,8 +25,16 @@ export function useRelativeTime(): Formatter {
2525 formatters . set ( locale . value , formatterRef )
2626 }
2727
28- return ( value : Date | number ) => {
28+ return ( value : Date | number | null | undefined ) => {
29+ if ( value == null ) {
30+ return ''
31+ }
32+
2933 const date = value instanceof Date ? value : new Date ( value )
34+
35+ if ( Number . isNaN ( date . getTime ( ) ) ) {
36+ return ''
37+ }
3038 const now = Date . now ( )
3139 const diff = date . getTime ( ) - now
3240
You can’t perform that action at this time.
0 commit comments