fix: display meeting times from ISO offset string, not browser timezone
This commit is contained in:
+33
-11
@@ -349,31 +349,53 @@
|
|||||||
return "green";
|
return "green";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse the wall-clock date/time directly from an ISO-8601 string that
|
||||||
|
// already carries an offset (e.g. "2026-03-31T10:00:00-03:00").
|
||||||
|
// We never let the browser re-interpret it into its own timezone.
|
||||||
|
function parseISOParts(dateTimeStr) {
|
||||||
|
// Matches: YYYY-MM-DDTHH:MM:SS(±HH:MM or Z)
|
||||||
|
const m = dateTimeStr.match(
|
||||||
|
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::\d{2})?/,
|
||||||
|
);
|
||||||
|
if (!m) return null;
|
||||||
|
return {
|
||||||
|
year: parseInt(m[1], 10),
|
||||||
|
month: parseInt(m[2], 10),
|
||||||
|
day: parseInt(m[3], 10),
|
||||||
|
hour: parseInt(m[4], 10),
|
||||||
|
minute: parseInt(m[5], 10),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function formatLocalTime(dateTimeStr) {
|
function formatLocalTime(dateTimeStr) {
|
||||||
const d = new Date(dateTimeStr);
|
const p = parseISOParts(dateTimeStr);
|
||||||
return d.toLocaleTimeString([], {
|
if (!p) return "";
|
||||||
hour: "2-digit",
|
const h = String(p.hour).padStart(2, "0");
|
||||||
minute: "2-digit",
|
const m = String(p.minute).padStart(2, "0");
|
||||||
hour12: false,
|
return `${h}:${m}`;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatLocalDate(dateTimeStr) {
|
function formatLocalDate(dateTimeStr) {
|
||||||
const d = new Date(dateTimeStr);
|
const p = parseISOParts(dateTimeStr);
|
||||||
|
if (!p) return "";
|
||||||
|
// Build a UTC date just for the locale label so day/month names are correct
|
||||||
|
const d = new Date(Date.UTC(p.year, p.month - 1, p.day));
|
||||||
return d.toLocaleDateString([], {
|
return d.toLocaleDateString([], {
|
||||||
weekday: "short",
|
weekday: "short",
|
||||||
month: "short",
|
month: "short",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
|
timeZone: "UTC",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function isToday(dateTimeStr) {
|
function isToday(dateTimeStr) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const d = new Date(dateTimeStr);
|
const p = parseISOParts(dateTimeStr);
|
||||||
|
if (!p) return false;
|
||||||
return (
|
return (
|
||||||
d.getFullYear() === now.getFullYear() &&
|
p.year === now.getFullYear() &&
|
||||||
d.getMonth() === now.getMonth() &&
|
p.month === now.getMonth() + 1 &&
|
||||||
d.getDate() === now.getDate()
|
p.day === now.getDate()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user