updates on the fix
This commit is contained in:
22
src/utils/doormileTimestamp.js
Normal file
22
src/utils/doormileTimestamp.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
// Doormile timestamps are IST (Asia/Kolkata) wall-clock stored in Postgres
|
||||
// `timestamp without time zone` columns (express-console-api.md, "Conventions
|
||||
// across every endpoint"). Some responses come back with a trailing Z/offset
|
||||
// anyway — a known Go+pgx footgun where a naive DB timestamp loads into
|
||||
// time.Time under UTC location and gets marshaled with a false "Z" suffix.
|
||||
// dayjs treats a Z-suffixed string as a real UTC instant and converts it to
|
||||
// the browser's local time on display/bucketing, adding a spurious +5:30 on
|
||||
// top of digits that were already correct IST.
|
||||
//
|
||||
// Stripping any trailing zone marker before parsing makes both cases (truly
|
||||
// naive, or naive-with-false-Z) render/bucket identically as the raw
|
||||
// wall-clock digits. Shared by orders.js (row date cells), deliveries.js and
|
||||
// Dispatch.js (`assigntime`-based batch bucketing — CLAUDE.md requires both
|
||||
// pages agree on which batch a row belongs to, so both must use the same
|
||||
// parse).
|
||||
export const parseDoormileTimestamp = (raw) => {
|
||||
if (!raw) return dayjs(null);
|
||||
const stripped = String(raw).replace(/(Z|[+-]\d{2}:?\d{2})$/, '');
|
||||
return dayjs(stripped);
|
||||
};
|
||||
Reference in New Issue
Block a user