Initial commit: Add project files
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
export function formatCurrency(value: number | null | undefined, currency: string, locale = 'ko-KR'): string {
|
||||
if (value == null || Number.isNaN(value)) return '—'
|
||||
return new Intl.NumberFormat(locale, { style: 'currency', currency, maximumFractionDigits: 2 }).format(value)
|
||||
}
|
||||
export function formatPercent(value: number | null | undefined, digits = 2, locale = 'ko-KR'): string {
|
||||
if (value == null || Number.isNaN(value)) return '—'
|
||||
return new Intl.NumberFormat(locale, { style: 'percent', minimumFractionDigits: digits, maximumFractionDigits: digits }).format(value)
|
||||
}
|
||||
export function formatQuantity(value: number | null | undefined, digits = 4, locale = 'ko-KR'): string {
|
||||
if (value == null || Number.isNaN(value)) return '—'
|
||||
return new Intl.NumberFormat(locale, { maximumFractionDigits: digits }).format(value)
|
||||
}
|
||||
export function formatAsOf(value: string | Date | null | undefined, locale = 'ko-KR'): string {
|
||||
if (!value) return '—'
|
||||
const date = value instanceof Date ? value : new Date(value)
|
||||
if (Number.isNaN(date.getTime())) return '—'
|
||||
return new Intl.DateTimeFormat(locale, { dateStyle: 'medium', timeStyle: 'short', timeZone: 'Asia/Seoul' }).format(date)
|
||||
}
|
||||
Reference in New Issue
Block a user