feat: batch details

This commit is contained in:
Jannat Patel
2024-01-05 18:22:03 +05:30
parent 10cdd712d2
commit 3a33f047f5
15 changed files with 1215 additions and 662 deletions

View File

@@ -11,3 +11,31 @@ export function createToast(options) {
export function timeAgo(date) {
return useTimeAgo(date).value
}
export function formatTime(timeString) {
if (!timeString) return ''
const [hour, minute] = timeString.split(':').map(Number)
// Create a Date object with dummy values for day, month, and year
const dummyDate = new Date(0, 0, 0, hour, minute)
// Use Intl.DateTimeFormat to format the time in 12-hour format
const formattedTime = new Intl.DateTimeFormat('en-US', {
hour: 'numeric',
minute: 'numeric',
hour12: true,
}).format(dummyDate)
return formattedTime
}
export function formatNumberIntoCurrency(number, currency) {
if (number) {
return number.toLocaleString('en-IN', {
maximumFractionDigits: 0,
style: 'currency',
currency: currency,
})
}
return ''
}