Skip to content

fix(events): stamp the ICS feed's DTSTAMP and LAST-MODIFIED in UTC - #1161

Merged
sydevs-bot merged 4 commits into
mainfrom
claude/fix-1158-ics-utc-timestamps
Nov 16, 2026
Merged

sydevs-bot merged 4 commits into
mainfrom
claude/fix-1158-ics-utc-timestamps

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • DTSTAMP and LAST-MODIFIED are now UTC with a Z, in both the calendar feed and the registration-confirmation attachment, instead of the rendering host's wall clock.
  • Joined, from the same line: RRULE;UNTIL and a tzid-less event's DTSTART/DTEND were floating times, and are now UTC instants. Neither was pinned by a test.
  • From review: both vitest lanes now run in Asia/Tokyo, so the class of defect behind all of the above fails CI instead of hiding behind a UTC runner.

Change outline

Contract — what a calendar client receives

One line decides all of it. ical-generator renders a different set of properties through the calendar zone than through the event zone, and only the first set was wrong.

  // src/lib/schedule/icsBuilder.ts
  ical({
-   timezone: { name: timezone, generator: getVtimezoneComponent },
+   timezone: { name: null,     generator: getVtimezoneComponent },
  })

Rendered through the calendar zone — all fixed by that line:

- DTSTAMP:20261115T110157                      // host wall clock, no Z
+ DTSTAMP:20261115T180157Z
- LAST-MODIFIED:20260801T030000                // host wall clock, no Z
+ LAST-MODIFIED:20260801T100000Z
- RRULE:FREQ=WEEKLY;UNTIL=20260930T235900      // floating
+ RRULE:FREQ=WEEKLY;UNTIL=20260930T225900Z
- TIMEZONE-ID:Europe/London                    // non-standard, nothing reads it
- X-WR-TIMEZONE:Europe/London                  // non-standard, nothing reads it

Rendered through the event zone — unchanged, and asserted so:

  DTSTART;TZID=Europe/London:20260721T190000
  DTEND;TZID=Europe/London:20260721T210000
  EXDATE;TZID=Europe/London:…
  BEGIN:VTIMEZONE / TZID:Europe/London / BEGIN:STANDARD / BEGIN:DAYLIGHT

An event whose rule carries no TZID falls back to 'UTC', and that path moves too — out of floating time, which a client reads as its own local time:

- DTSTART:20260721T180000                      // floating: no TZID, no Z
+ DTSTART:20260721T180000Z
- BEGIN:VTIMEZONE … TZID:UTC … DTSTART:19700101T000000   // epoch-dated, useless
+ (no VTIMEZONE — a UTC instant needs none)

Behaviour — why a non-null name was wrong

formatDate(zone, date)                 // ical-generator
  zone != null  → getHours()/getMinutes()   ← the HOST clock, and no `Z`
  zone == null  → getUTCHours()  + `Z`

The zone argument is only a flag here: for a Date it is never applied, so the hours came from whatever machine rendered the document. The VTIMEZONE set is built from the calendar zone plus every event's own zone, so dropping the calendar's name keeps the component Apple needs.

Guard — why the lane moved off UTC

Code reading the host clock where an instant is required renders the correct text on a UTC host. CI runs UTC, so the assertion that pinned LAST-MODIFIED stayed green for the whole life of the bug, and acceptance criterion 4 could only be met by a TZ= prefix someone remembers to type.

  // vitest.config.mts — sharedTestEnv, read by both the unit and int projects
   NODE_ENV: 'test',
+  TZ: 'Asia/Tokyo',

Watched failing: with the pin in place and no TZ= prefix, main's pre-fix icsBuilder.ts and spec report 1 failed, 25 passed — LAST-MODIFIED:20260801T190000 against the expected …T100000. Asia/Tokyo rather than a DST zone, so the offset is a constant whole hour and no case depends on the date it runs.

Preview

  • Events list — an event's Calendar feed URL field is the .ics this PR changes
  • Registrations list — the confirmation email's attachment is built by the same function

Data: not seeded yet. previewUrl.seed is unset for this repo, so nothing seeds a preview automatically, and both links open on an empty list until someone creates an event. The wire format is covered by the unit lane instead — see Manual verification for the one-minute hand check.

Test results

  • Lean gate: ✓ lint, format:check, typecheck (src), typecheck (tests), 3878 unit tests in 282 files
  • Targeted specs: tests/unit/ics-builder.spec.ts 28 passed under TZ=UTC, TZ=America/Vancouver and TZ=Asia/Tokyo; tests/int/event-calendar-feed.int.spec.ts 22 passed
  • Whole int lane, once, because sharedTestEnv reaches it too: 1972 passed in 109 files under the pin
  • Build: N/A — Railway builds on the preview

Every new assertion was watched failing against the reverted line, under TZ=UTC and TZ=Asia/Tokyo: 4 failed, 24 passed in both.

Manual verification

The acceptance criteria are covered by the unit lane. What it cannot reach is a real client parsing the document:

  1. Create and publish an event in the preview, with a timezone that is not UTC and an end date.
  2. Open its Calendar feed URL and subscribe to the .ics in Apple Calendar and Google Calendar.
  3. Confirm the event lands at the right wall-clock time, and that the series stops on the end date.

Notes for reviewer

  • One judgement call. Acceptance criterion 2 says DTSTART/DTEND/EXDATE stay TZID-qualified. For a zoned event they do, and that is asserted. For an event whose zone resolves to UTC they are now …Z instants with no TZID, because RFC 5545 spells UTC that way and never as TZID=UTC. They were floating before, so nothing regressed — but it is a spelling change the criterion does not literally cover.
  • Two dropped headers, TIMEZONE-ID and X-WR-TIMEZONE. Both are non-standard, and grep finds no reader in this repo. They go with the calendar name; keeping them would mean keeping the defect.
  • Dismissed, 2 of 2 comment-lint findings — both "points at a section number". They cite RFC 5545 §3.3.10 and §3.8.7.x. The code-comments rule names an RFC as a fine breadcrumb; the linter cannot tell a published RFC's section from a project doc's. Each comment also states the rule in full, so it survives its link being cut.
  • The /code-review high pass found 3 issues, all fixed in c293574, which is also where the joined UNTIL and UTC-zone coverage lives.
Detail

Why not pass the zone through instead. formatDate ignores the zone argument for a Date — it only branches on whether it is null. There is no value that yields "render in Europe/London with an offset"; the only correct output for these properties is UTC, which is what RFC 5545 §3.8.7.2 and §3.8.7.3 require anyway.

Why the old assertion was green on CI. It pinned LAST-MODIFIED:20260801T100000 with no Z, and CI runs UTC, so the host clock agreed with the intended value. Under TZ=America/Vancouver the same input rendered 20260801T030000. The spec's comment attributed this to the calendar zone rendering "in that zone" — had that been true the value would have been London's 11:00, not Vancouver's 03:00.

Why UNTIL needed a stronger assertion. It read toContain('UNTIL=20260930'). The date part is identical before and after, so it passed against both the floating and the UTC spelling and could not catch a revert.

Measurement note. An early reading of this branch suggested a tzid-less DTSTART was emitted at the epoch. That was an unscoped startsWith('DTSTART') matching the VTIMEZONE's own transition line — the trap the spec's vevent() helper documents. The epoch date is real, but it belongs to the spurious UTC VTIMEZONE, which this change removes.

Closes #1158

🤖 Written by the sydevs autonomous loop — see what this is

ical-generator renders those two properties through the CALENDAR timezone
(`formatDate(this.calendar.timezone(), …)`), not the event's. Any non-null
value sends `formatDate` down its local-components branch, which drops the `Z`
and reads the hours off `getHours()` — the rendering host's clock, not the zone
named there. RFC 5545 §3.8.7.2 and §3.8.7.3 require UTC for both.

Setting `name: null` keeps the generator, and the VTIMEZONE set is built from
the calendar zone plus every event's own zone, so the component Apple needs
still ships. `DTSTART`, `DTEND` and `EXDATE` go through the event's zone and
are unchanged. Two non-standard headers go with the name, `TIMEZONE-ID` and
`X-WR-TIMEZONE`; nothing in this repo reads either.

The spec's comment explained the missing `Z` as the calendar zone rendering
every timestamp "in that zone". It was the host's zone: under
TZ=America/Vancouver a 10:00Z LAST-MODIFIED rendered as 03:00, not London's
11:00. The new case pins the `Z` on both surfaces and fails under TZ=UTC too,
where the old assertion was green.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXCZHrsVMDKFu1VAtN
The calendar zone also fed `RRULE;UNTIL` and, where the rule carries no TZID,
`DTSTART`/`DTEND`. Both were floating — no TZID and no `Z` — which a client
reads as its own local time. They are now UTC instants, and the spurious
VTIMEZONE a UTC zone generated, dated at the epoch, is gone.

Neither was pinned. `toContain('UNTIL=20260930')` matches the date part, which
is identical either way, so it could not tell the conformant UNTIL from the
floating one. Nothing covered the tzid-less path at all.

Also drops a claim that the new DTSTAMP case only bites under a non-UTC TZ. The
missing `Z` fails it under every host zone, and reading otherwise invites
deleting the one guard for this defect as vacuous.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXCZHrsVMDKFu1VAtN
@railway-app

railway-app Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-1161 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Nov 15, 2026 at 7:07 pm UTC
1 service not affected by this PR
  • mailpit

@sydevs-bot

sydevs-bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running
pending since 17:16Z

recent dispatches
  • 18:47Z address-review · attempt 1 · session · done
  • 18:47Z address-review · attempt 1 · session
  • 18:39Z review-pr · attempt 1 · session · done
  • 18:39Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 15, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 15, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

One production line, plus the assertions that pin it. As small as the problem allows, and the body's account of the library holds: formatDate takes its getHours() branch on any non-null zone (ical-generator/src/tools.ts:286), and calendar.ts:639 builds the VTIMEZONE set from the calendar zone plus every event's own, so dropping the name keeps the component Apple needs. The three joined assertions — UNTIL, the UTC-zone spelling, DTSTAMP on both surfaces — pin other outputs of that same line, so they join rather than smuggle. Nothing this repo or a sibling reads moved: TIMEZONE-ID and X-WR-TIMEZONE have no reader in src/, tests/ or docs/. One gap: the fix closes the instance and leaves the class open.

Findings

  • should-fix — the lane pins no TZ and CI runs UTC, so the next host-clock assertion lands green again. tests/unit/ics-builder.spec.ts:330.

What was checked

  • Read icsBuilder.ts and ics-builder.spec.ts whole on the branch, plus both callers (calendarFeed.ts:204, sendRegistrationConfirmation.ts:70) — buildEventCalendar is the only ical-generator entry point in the repo.
  • Walked the ladder: the diff adds no file, helper, type or dependency. { name: null, generator } is the library's own shape, not a workaround.
  • Verified the before/after in the library, not from the body: formatDateTZ reads TZID off data.timezone, so a UTC event's DTSTART really was floating.
  • CREATED also renders through the calendar zone; this builder never sets it.
  • Preview: pr-1161.cloud-preview.sydevelopers.com answers 302 to the Access login. This run holds no service token, so the preview is unreachable, not empty.
  • Measurement behind the finding: TZ=Asia/Tokyo pnpm test:unit on main — 1 failed, 281 files green.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread tests/unit/ics-builder.spec.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 15, 2026
The defect #1161 fixes renders correctly on a UTC host, so CI's UTC runner
saw the right text and the assertion that pinned it stayed green for the
whole life of the bug. Criterion 4 of #1158 — the spec passes under a
non-UTC process timezone — was left to a hand-run `TZ=` prefix, which
nothing repeats.

Pinning `TZ` in `sharedTestEnv` makes the lane itself the guard. Watched
failing: with the pin in place and no `TZ=` prefix, `main`'s pre-fix
`icsBuilder.ts` and spec report 1 failed, 25 passed. Both lanes are green
with it on this branch — unit 3878 in 282 files, int 1972 in 109 files.

Asia/Tokyo rather than a DST zone: a constant whole-hour offset keeps a
divergence unambiguous, and no case then depends on the date it runs.

Raised in review: #1161 (comment)

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVYptVDhw6qizzv8PQ
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1161 November 15, 2026 19:03 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Pushed 0842f9d. One finding, adopted.

Adopted — the lane pins no TZ. TZ: 'Asia/Tokyo' now sits in sharedTestEnv, so acceptance criterion 4 is enforced by the lane instead of a TZ= prefix someone types. Watched failing against main's pre-fix builder: 1 failed, 25 passed. Unit 3878 in 282 files and int 1972 in 109 are green under it — the int lane measured because sharedTestEnv reaches it too.

origin/main merged in cleanly, no conflicts. Body refreshed: the pin has its own ## Change outline section, since the old one said one line decided everything.

Lean gate: ✓.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 15, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 15, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 15, 2026 19:15
@sydevs-bot
sydevs-bot requested a review from Ardnived November 15, 2026 19:15
@sydevs-bot
sydevs-bot enabled auto-merge November 15, 2026 19:15
@sydevs-bot sydevs-bot moved this from Pending to Awaiting in SYDevelopers Technical Roadmap Nov 15, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 16, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 7d4b7a8 Nov 16, 2026
39 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-1158-ics-utc-timestamps branch November 16, 2026 17:35

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1161 — 0842f9db Deployed Nov 15, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(events): stamp the ICS feed's DTSTAMP and LAST-MODIFIED in UTC

3 participants