first commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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)}`
|
||||
}
|
||||
Reference in New Issue
Block a user