diff --git a/packages/shared/src/utils/mudPoints.ts b/packages/shared/src/utils/mudPoints.ts index d65ec3ba3..080bdfbd8 100644 --- a/packages/shared/src/utils/mudPoints.ts +++ b/packages/shared/src/utils/mudPoints.ts @@ -64,6 +64,22 @@ export function shouldShowProfileDailyFreePool( ); } +/** + * 月度泥点刷新时刻的格式化器:locale / 时区 / 字段固定,提到模块级复用。 + * + * 固定 `Asia/Shanghai` 与 ADR「会员账期按开通日自然月」一致;`hourCycle: 'h23'` 避免 + * 午夜格式化成 24 点。该 formatter 会在多个渲染路径里被反复调用,构建一次即可。 + */ +const MUD_POINT_RESET_FORMATTER = new Intl.DateTimeFormat('en-CA', { + timeZone: 'Asia/Shanghai', + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + hourCycle: 'h23', +}); + /** * 月度泥点的刷新时刻展示文案。 * @@ -80,15 +96,7 @@ export function formatMudPointResetAt( if (Number.isNaN(parsed.getTime())) { return null; } - const parts = new Intl.DateTimeFormat('en-CA', { - timeZone: 'Asia/Shanghai', - year: 'numeric', - month: '2-digit', - day: '2-digit', - hour: '2-digit', - minute: '2-digit', - hourCycle: 'h23', - }).formatToParts(parsed); + const parts = MUD_POINT_RESET_FORMATTER.formatToParts(parsed); const lookup = (type: Intl.DateTimeFormatPartTypes) => parts.find((part) => part.type === type)?.value ?? '00'; return `${lookup('year')}-${lookup('month')}-${lookup('day')} ${lookup('hour')}:${lookup(