fix(dreaming): include timezone label in diary timestamps (#65057)

Dream diary entries in DREAMS.md and the Control UI show bare
timestamps without any timezone indicator. When users have not
configured a timezone, timestamps are rendered in UTC but appear to be
local time, causing confusion.

Add timeZoneName: "short" to the Intl.DateTimeFormat options in
formatNarrativeDate so timestamps always include a timezone
abbreviation (e.g. "9:46 PM UTC" or "2:46 PM PDT").

Fixes #65027
This commit is contained in:
Yanhu
2026-04-12 23:48:40 +08:00
committed by GitHub
parent 156ee544ed
commit 3ef8f0edd8
3 changed files with 9 additions and 0 deletions

View File

@@ -121,6 +121,7 @@ describe("formatNarrativeDate", () => {
expect(date).toContain("April");
expect(date).toContain("2026");
expect(date).toContain("3:00");
expect(date).toContain("UTC");
});
it("applies an explicit timezone", () => {
@@ -131,6 +132,7 @@ describe("formatNarrativeDate", () => {
);
expect(date).toContain("2:46");
expect(date).toContain("PM");
expect(date).toContain("PDT");
});
it("uses host local timezone when timezone is undefined (#65027)", () => {
@@ -144,6 +146,7 @@ describe("formatNarrativeDate", () => {
// 21:46 UTC → 14:46 PDT → "2:46 PM"
expect(result).toContain("2:46");
expect(result).toContain("PM");
expect(result).toContain("PDT");
} finally {
if (originalTZ === undefined) {
delete process.env.TZ;

View File

@@ -238,6 +238,11 @@ export function formatNarrativeDate(epochMs: number, timezone?: string): string
hour: "numeric",
minute: "2-digit",
hour12: true,
// Always include the timezone abbreviation so the reader knows which
// timezone the timestamp refers to. Without this, users who haven't
// configured a timezone see bare times that look local but are actually
// UTC, causing confusion (see #65027).
timeZoneName: "short",
};
return new Intl.DateTimeFormat("en-US", opts).format(new Date(epochMs));
}