28 lines
751 B
TypeScript
28 lines
751 B
TypeScript
const DISPLAY_LOCALE = "en-LK"
|
|
const DISPLAY_TIME_ZONE = "Asia/Colombo"
|
|
|
|
/** Formatting is explicit so SSR and browser renders produce the same output. */
|
|
export function formatCurrency(amount: number) {
|
|
return `Rs. ${amount.toLocaleString(DISPLAY_LOCALE)}`
|
|
}
|
|
|
|
export function formatTime(iso: string) {
|
|
return new Date(iso).toLocaleTimeString(DISPLAY_LOCALE, {
|
|
hour: "numeric",
|
|
minute: "2-digit",
|
|
timeZone: DISPLAY_TIME_ZONE,
|
|
})
|
|
}
|
|
|
|
export function formatDate(iso: string) {
|
|
return new Date(iso).toLocaleDateString(DISPLAY_LOCALE, {
|
|
month: "short",
|
|
day: "numeric",
|
|
year: "numeric",
|
|
timeZone: DISPLAY_TIME_ZONE,
|
|
})
|
|
}
|
|
|
|
export function formatDateTime(iso: string) {
|
|
return `${formatDate(iso)}, ${formatTime(iso)}`
|
|
} |