You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(core): normalize scheduledAt to UTC in content.schedule() (#2913)
* fix(core): normalize scheduledAt to UTC in content.schedule()
content.schedule() stored the caller-supplied scheduledAt string
verbatim, even though it already parses it into a Date for validation.
findReadyToPublish() compares scheduled_at against
new Date().toISOString() (always UTC/"Z") using plain string
ordering, so a non-UTC offset (e.g. "+09:00") sorts incorrectly and
the item publishes up to that many hours late (or early, for offsets
ahead of UTC).
Reuses the already-validated scheduledDate and stores
scheduledDate.toISOString() instead of the raw input.
Fixes#2896
* fix(core): normalize scheduledAt in update() and replaceDraftRevisionForUpdate() too
Per review: schedule() normalized scheduledAt to UTC, but the sibling
write paths in update() and replaceDraftRevisionForUpdate() still
stored UpdateContentInput.scheduledAt verbatim, leaving the same
late/early-publish bug reachable through any caller that reaches
those methods with a non-UTC offset.
Extracts a private normalizeScheduledAt() helper (validates and
normalizes, passing null through for unschedule-via-update) and
applies it at both remaining write sites. Also added regression tests
for update() (offset normalization, null clears the field, invalid
string still rejected) and reworded the changeset to describe the
user-facing behavior rather than internal mechanics, per review.
replaceDraftRevisionForUpdate() has no existing unit-test scaffold in
this file (only reachable via updateDraftAware(), which needs a
revisions-enabled collection fixture not currently set up in this
suite) and this environment can't run the test suite to validate a
new one, so no test was added for that path specifically — flagging
this explicitly rather than guessing.
* style: format
* test(core): assert normalized schedule timestamps
* test(core): cover UTC scheduling boundaries
---------
Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
Co-authored-by: Matt Kane <mkane@cloudflare.com>
Fixes `content.schedule()` and content updates so offset dates are stored as canonical UTC ISO 8601 timestamps. Positive and negative offsets now publish at the represented instant instead of several hours late or early.
0 commit comments