Files
thebet365/apps/admin/src/utils/format-datetime.ts
Mars a3e8958406 sync(theme-4): 从 main 同步优胜赛结算态与钱包流水展示优化
- checkout shared/api/admin 自 d3c2114
- player: outright 结算态逻辑、wallet txAmountClass、i18n 新增 key(保留海军蓝主题样式)
2026-06-23 13:53:20 +08:00

40 lines
1010 B
TypeScript

import { getAdminLocale } from '../i18n';
import type { AdminLocale } from '../i18n/admin-messages';
function resolveLocale(locale?: AdminLocale): AdminLocale {
return locale ?? getAdminLocale();
}
/** 列表展示:年月日 */
export function formatAdminDateTimeBrief(
value: string | null | undefined,
locale?: AdminLocale,
): string {
if (!value) return '—';
const d = new Date(value);
if (Number.isNaN(d.getTime())) return '—';
return d.toLocaleString(resolveLocale(locale), {
year: 'numeric',
month: '2-digit',
day: '2-digit',
});
}
/** 悬停详情:含秒 */
export function formatAdminDateTimeFull(
value: string | null | undefined,
locale?: AdminLocale,
): string {
if (!value) return '—';
const d = new Date(value);
if (Number.isNaN(d.getTime())) return '—';
return d.toLocaleString(resolveLocale(locale), {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
});
}