|
- export const manhourFormatter = new Intl.NumberFormat("en-HK", {
- minimumFractionDigits: 2,
- maximumFractionDigits: 2,
- });
-
- export const moneyFormatter = new Intl.NumberFormat("en-HK", {
- style: "currency",
- currency: "HKD",
- });
-
- export const percentFormatter = new Intl.NumberFormat("en-HK", {
- style: "percent",
- maximumFractionDigits: 2,
- });
-
- export const INPUT_DATE_FORMAT = "YYYY-MM-DD";
-
- const shortDateFormatter_en = new Intl.DateTimeFormat("en-HK", {
- weekday: "short",
- year: "numeric",
- month: "short",
- day: "numeric",
- });
-
- const shortDateFormatter_zh = new Intl.DateTimeFormat("zh-HK", {
- weekday: "long",
- year: "numeric",
- month: "numeric",
- day: "numeric",
- });
-
- export const shortDateFormatter = (locale?: string) => {
- switch (locale) {
- case "zh":
- return shortDateFormatter_zh;
- case "en":
- default:
- return shortDateFormatter_en;
- }
- };
-
- export function convertLocaleStringToNumber(numberString: string): number {
- const numberWithoutCommas = numberString.replace(/,/g, "");
- return parseFloat(numberWithoutCommas);
- }
|