cal.pub0.org/packages/lib/price.ts

12 lines
338 B
TypeScript
Raw Permalink Normal View History

export const formatPrice = (price: number, currency: string | undefined, locale = "en") => {
switch (currency) {
case "BTC":
return `${price} sats`;
default:
return `${Intl.NumberFormat(locale, {
style: "currency",
currency: currency?.toUpperCase() || "USD",
}).format(price / 100.0)}`;
}
};