Files
device-voice-h5/utils/display.js
luo 4f281da778
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 1m11s
feat: 7月迭代
2026-07-27 18:13:19 +08:00

19 lines
562 B
JavaScript

export const formatMoney = (amount) => {
if (amount === null || amount === undefined || amount === '') return '0.00';
const cents = Number(amount);
if (!Number.isFinite(cents)) return '0.00';
return (cents / 100).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
};
export const formatDate = (value, fallback = '-') => {
if (!value) return fallback;
return String(value).replace('T', ' ').slice(0, 10);
};
export const formatDateTime = (value, fallback = '-') => {
if (!value) return fallback;
return String(value).replace('T', ' ').slice(0, 19);
};