|
@@ -10,6 +10,7 @@ import { |
|
|
take, |
|
|
take, |
|
|
} from "lodash"; |
|
|
} from "lodash"; |
|
|
import { Box, BoxProps } from "@mui/material"; |
|
|
import { Box, BoxProps } from "@mui/material"; |
|
|
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
|
|
|
|
|
export const manhourFormatter = new Intl.NumberFormat("en-HK", { |
|
|
export const manhourFormatter = new Intl.NumberFormat("en-HK", { |
|
|
minimumFractionDigits: 2, |
|
|
minimumFractionDigits: 2, |
|
@@ -23,7 +24,7 @@ export const moneyFormatter = new Intl.NumberFormat("en-HK", { |
|
|
|
|
|
|
|
|
export const decimalFormatter = new Intl.NumberFormat("en-HK", { |
|
|
export const decimalFormatter = new Intl.NumberFormat("en-HK", { |
|
|
minimumFractionDigits: 2, |
|
|
minimumFractionDigits: 2, |
|
|
maximumFractionDigits: 2, |
|
|
|
|
|
|
|
|
maximumFractionDigits: 5, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
export const integerFormatter = new Intl.NumberFormat("en-HK", {}); |
|
|
export const integerFormatter = new Intl.NumberFormat("en-HK", {}); |
|
@@ -69,6 +70,7 @@ export const dayjsToDateString = (date: Dayjs) => { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export const minutesToHoursMinutes = (minutes: number): string => { |
|
|
export const minutesToHoursMinutes = (minutes: number): string => { |
|
|
|
|
|
const { t } = useTranslation("common"); |
|
|
const defaultHrStr = "hr" |
|
|
const defaultHrStr = "hr" |
|
|
const defaultMinStr = "min" |
|
|
const defaultMinStr = "min" |
|
|
|
|
|
|
|
@@ -81,16 +83,16 @@ export const minutesToHoursMinutes = (minutes: number): string => { |
|
|
|
|
|
|
|
|
let finalHrStr: string = "" |
|
|
let finalHrStr: string = "" |
|
|
if (hrs > 1) { |
|
|
if (hrs > 1) { |
|
|
finalHrStr = `${hrs} ${defaultHrStr}s` |
|
|
|
|
|
|
|
|
finalHrStr = `${hrs} `+ t(`${defaultHrStr}s`) |
|
|
} else if (hrs == 1) { |
|
|
} else if (hrs == 1) { |
|
|
finalHrStr = `1 ${defaultHrStr}` |
|
|
|
|
|
|
|
|
finalHrStr = `1 `+ t(`${defaultHrStr}`) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let finalMinStr: string = "" |
|
|
let finalMinStr: string = "" |
|
|
if (mins > 1) { |
|
|
if (mins > 1) { |
|
|
finalMinStr = `${mins} ${defaultMinStr}s` |
|
|
|
|
|
|
|
|
finalMinStr = `${mins} ` + t(`${defaultMinStr}s`) |
|
|
} else if (mins == 1) { |
|
|
} else if (mins == 1) { |
|
|
finalMinStr = `1 ${defaultMinStr}` |
|
|
|
|
|
|
|
|
finalMinStr = `1 ` + t(`${defaultMinStr}`) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const colon = finalHrStr.length > 0 && finalMinStr.length > 0 ? ":" : "" |
|
|
const colon = finalHrStr.length > 0 && finalMinStr.length > 0 ? ":" : "" |
|
|