20 lines
500 B
TypeScript
20 lines
500 B
TypeScript
export function money(cents: number) {
|
|
return `¥${(Number(cents || 0) / 100).toFixed(2)}`;
|
|
}
|
|
|
|
export function shortDate(value?: string | null) {
|
|
if (!value) return '-';
|
|
const date = new Date(value);
|
|
if (Number.isNaN(date.getTime())) return '-';
|
|
return date.toLocaleString('zh-CN', {
|
|
month: '2-digit',
|
|
day: '2-digit',
|
|
hour: '2-digit',
|
|
minute: '2-digit'
|
|
});
|
|
}
|
|
|
|
export function compactText(value?: string | null) {
|
|
return value && value.trim().length > 0 ? value : '-';
|
|
}
|