您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

46 行
1.0 KiB

  1. export const manhourFormatter = new Intl.NumberFormat("en-HK", {
  2. minimumFractionDigits: 2,
  3. maximumFractionDigits: 2,
  4. });
  5. export const moneyFormatter = new Intl.NumberFormat("en-HK", {
  6. style: "currency",
  7. currency: "HKD",
  8. });
  9. export const percentFormatter = new Intl.NumberFormat("en-HK", {
  10. style: "percent",
  11. maximumFractionDigits: 2,
  12. });
  13. export const INPUT_DATE_FORMAT = "YYYY-MM-DD";
  14. const shortDateFormatter_en = new Intl.DateTimeFormat("en-HK", {
  15. weekday: "short",
  16. year: "numeric",
  17. month: "short",
  18. day: "numeric",
  19. });
  20. const shortDateFormatter_zh = new Intl.DateTimeFormat("zh-HK", {
  21. weekday: "long",
  22. year: "numeric",
  23. month: "numeric",
  24. day: "numeric",
  25. });
  26. export const shortDateFormatter = (locale?: string) => {
  27. switch (locale) {
  28. case "zh":
  29. return shortDateFormatter_zh;
  30. case "en":
  31. default:
  32. return shortDateFormatter_en;
  33. }
  34. };
  35. export function convertLocaleStringToNumber(numberString: string): number {
  36. const numberWithoutCommas = numberString.replace(/,/g, "");
  37. return parseFloat(numberWithoutCommas);
  38. }