From d42392dfc5ad21c9ca4ede4473487d354ca1e860 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Mon, 10 Aug 2026 14:06:56 +0800 Subject: [PATCH] test: format port schedule fixtures in Shanghai local time --- .../admin-test-env-modules/phase3-port-schedules.mjs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/admin-test-env-modules/phase3-port-schedules.mjs b/scripts/admin-test-env-modules/phase3-port-schedules.mjs index 435b661fe..0cc38a07a 100644 --- a/scripts/admin-test-env-modules/phase3-port-schedules.mjs +++ b/scripts/admin-test-env-modules/phase3-port-schedules.mjs @@ -7,7 +7,15 @@ const OUTBOUND = '/api/platform/v1/first-leg/outbound-dispatches' function id(value) { return value == null ? '' : String(value) } function codeOf(response) { return response?.body?.code == null ? 'missing' : String(response.body.code) } function data(response) { return codeOf(response) === '200' ? response.body.data : null } -function localIso(value) { return value.toISOString().slice(0, 19) } +const SHANGHAI_TIME = new Intl.DateTimeFormat('en-CA', { + timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit', + hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23', +}) +function localIso(value) { + const parts = Object.fromEntries(SHANGHAI_TIME.formatToParts(value) + .filter((part) => part.type !== 'literal').map((part) => [part.type, part.value])) + return `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}` +} function at(offsetMinutes) { return localIso(new Date(Date.now() + offsetMinutes * 60_000)) } function step(context, name, response, passed, evidence) { context.addStep(MODULE, name, response, passed, evidence, { ...OPTIONS, deploymentBlocker: !passed })