From dd03192c462ea7be1804e8517e77ead59e2e7864 Mon Sep 17 00:00:00 2001 From: Spencer Smith Date: Tue, 3 Mar 2026 14:27:03 -0700 Subject: [PATCH 1/3] Add IANA timezone name to place context --- .../components/Context/injectPlaceContext.js | 4 +++ .../Context/injectPlaceContext.spec.js | 34 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/packages/core/src/components/Context/injectPlaceContext.js b/packages/core/src/components/Context/injectPlaceContext.js index 6c0bae743..209082a14 100644 --- a/packages/core/src/components/Context/injectPlaceContext.js +++ b/packages/core/src/components/Context/injectPlaceContext.js @@ -28,6 +28,10 @@ export default (dateProvider) => { ) { placeContext.localTime = toISOStringLocal(date); } + const localTimezoneName = Intl.DateTimeFormat().resolvedOptions().timeZone; + if (localTimezoneName) { + placeContext.localTimezoneName = localTimezoneName; + } event.mergeXdm({ placeContext }); }; diff --git a/packages/core/test/unit/specs/components/Context/injectPlaceContext.spec.js b/packages/core/test/unit/specs/components/Context/injectPlaceContext.spec.js index e6251f3ce..759bb0e2a 100644 --- a/packages/core/test/unit/specs/components/Context/injectPlaceContext.spec.js +++ b/packages/core/test/unit/specs/components/Context/injectPlaceContext.spec.js @@ -10,10 +10,18 @@ OF ANY KIND, either express or implied. See the License for the specific languag governing permissions and limitations under the License. */ -import { vi, describe, it, expect } from "vitest"; +import { vi, describe, it, expect, beforeEach } from "vitest"; import injectPlaceContext from "../../../../../src/components/Context/injectPlaceContext.js"; describe("Context::injectPlaceContext", () => { + beforeEach(() => { + vi.spyOn(Intl, "DateTimeFormat").mockImplementation(() => { + return { + resolvedOptions: () => ({ timeZone: "" }), + }; + }); + }); + it("adds placeContext", () => { const date = new Date("March 25, 2019 21:56:18"); vi.spyOn(date, "getTimezoneOffset").mockReturnValue(7 * 60); @@ -72,4 +80,28 @@ describe("Context::injectPlaceContext", () => { }, }); }); + it("includes localTimezoneName when Intl reports a timezone", () => { + vi.mocked(Intl.DateTimeFormat).mockImplementation(() => { + return { + resolvedOptions: () => ({ timeZone: "America/New_York" }), + }; + }); + const date = new Date("March 25, 2019 21:56:18"); + vi.spyOn(date, "getTimezoneOffset").mockReturnValue(4 * 60); + const event = { mergeXdm: vi.fn() }; + injectPlaceContext(() => date)(event); + expect(event.mergeXdm).toHaveBeenCalledWith({ + placeContext: expect.objectContaining({ + localTimezoneName: "America/New_York", + }), + }); + }); + it("omits localTimezoneName when Intl reports an empty timezone", () => { + const date = new Date("March 25, 2019 21:56:18"); + vi.spyOn(date, "getTimezoneOffset").mockReturnValue(4 * 60); + const event = { mergeXdm: vi.fn() }; + injectPlaceContext(() => date)(event); + const placeContext = event.mergeXdm.mock.calls[0][0].placeContext; + expect(placeContext).not.toHaveProperty("localTimezoneName"); + }); }); From c525f6270e9b386aafe408779a71c5c4328ecabb Mon Sep 17 00:00:00 2001 From: Spencer Smith Date: Wed, 4 Mar 2026 09:53:00 -0700 Subject: [PATCH 2/3] Add changeset --- .changeset/itchy-areas-help.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/itchy-areas-help.md diff --git a/.changeset/itchy-areas-help.md b/.changeset/itchy-areas-help.md new file mode 100644 index 000000000..b9e92d8a3 --- /dev/null +++ b/.changeset/itchy-areas-help.md @@ -0,0 +1,5 @@ +--- +"@adobe/alloy": patch +--- + +Include IANA timezone on the place context From 48a83967350d0cc482c762b734c4eff95101f1e6 Mon Sep 17 00:00:00 2001 From: Spencer Smith Date: Thu, 5 Mar 2026 09:26:19 -0700 Subject: [PATCH 3/3] Update key name --- .../core/src/components/Context/injectPlaceContext.js | 6 +++--- .../specs/components/Context/injectPlaceContext.spec.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/src/components/Context/injectPlaceContext.js b/packages/core/src/components/Context/injectPlaceContext.js index 209082a14..af0ea1980 100644 --- a/packages/core/src/components/Context/injectPlaceContext.js +++ b/packages/core/src/components/Context/injectPlaceContext.js @@ -28,9 +28,9 @@ export default (dateProvider) => { ) { placeContext.localTime = toISOStringLocal(date); } - const localTimezoneName = Intl.DateTimeFormat().resolvedOptions().timeZone; - if (localTimezoneName) { - placeContext.localTimezoneName = localTimezoneName; + const ianaTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + if (ianaTimezone) { + placeContext.ianaTimezone = ianaTimezone; } event.mergeXdm({ placeContext }); diff --git a/packages/core/test/unit/specs/components/Context/injectPlaceContext.spec.js b/packages/core/test/unit/specs/components/Context/injectPlaceContext.spec.js index 759bb0e2a..e2cbb4be5 100644 --- a/packages/core/test/unit/specs/components/Context/injectPlaceContext.spec.js +++ b/packages/core/test/unit/specs/components/Context/injectPlaceContext.spec.js @@ -80,7 +80,7 @@ describe("Context::injectPlaceContext", () => { }, }); }); - it("includes localTimezoneName when Intl reports a timezone", () => { + it("includes ianaTimezone when Intl reports a timezone", () => { vi.mocked(Intl.DateTimeFormat).mockImplementation(() => { return { resolvedOptions: () => ({ timeZone: "America/New_York" }), @@ -92,16 +92,16 @@ describe("Context::injectPlaceContext", () => { injectPlaceContext(() => date)(event); expect(event.mergeXdm).toHaveBeenCalledWith({ placeContext: expect.objectContaining({ - localTimezoneName: "America/New_York", + ianaTimezone: "America/New_York", }), }); }); - it("omits localTimezoneName when Intl reports an empty timezone", () => { + it("omits ianaTimezone when Intl reports an empty timezone", () => { const date = new Date("March 25, 2019 21:56:18"); vi.spyOn(date, "getTimezoneOffset").mockReturnValue(4 * 60); const event = { mergeXdm: vi.fn() }; injectPlaceContext(() => date)(event); const placeContext = event.mergeXdm.mock.calls[0][0].placeContext; - expect(placeContext).not.toHaveProperty("localTimezoneName"); + expect(placeContext).not.toHaveProperty("ianaTimezone"); }); });