26 lines
691 B
JavaScript
26 lines
691 B
JavaScript
const formatMoney = (amount, og) => {
|
|
const decimalPlaces = parseInt(og['chip_scale']);
|
|
const symbol = og['chip_symbol'];
|
|
const prefixed = og['chip_prefixed'];
|
|
|
|
const formatted = Number.parseFloat(amount).toFixed(decimalPlaces);
|
|
return prefixed ? `${symbol} ${formatted}` : `${formatted} ${symbol}`;
|
|
}
|
|
|
|
const formatTime = (amount) => {
|
|
const formatted = Number.parseInt(amount);
|
|
return `${formatted} hrs`;
|
|
}
|
|
|
|
const timestampToDate = (timestamp) => {
|
|
const dateOptions = { year: 'numeric', month: 'long', day: 'numeric' };
|
|
|
|
const date = new Date(timestamp);
|
|
return date.toLocaleDateString('en-GB', dateOptions);
|
|
}
|
|
|
|
export {
|
|
formatMoney,
|
|
formatTime,
|
|
timestampToDate
|
|
} |