diff options
Diffstat (limited to 'lib/utils.ts')
| -rw-r--r-- | lib/utils.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/utils.ts b/lib/utils.ts index 2eca9285..af9df057 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -28,10 +28,15 @@ export function formatDate( // Alternative: Create a separate function for date and time export function formatDateTime( - date: Date | string | number, + date: Date | string | number| null | undefined, locale: string = "en-US", opts: Intl.DateTimeFormatOptions = {} ) { + + if (date === null || date === undefined || date === '') { + return ''; // 또는 '-', 'N/A' 등 원하는 기본값 반환 + } + return new Intl.DateTimeFormat(locale, { month: opts.month ?? "long", day: opts.day ?? "numeric", |
