Skip to content

fix(admin): use local time for schedule minimum#2223

Closed
AaronBakerDev wants to merge 2 commits into
emdash-cms:mainfrom
AaronBakerDev:codex/scheduler-timezone-local-min
Closed

fix(admin): use local time for schedule minimum#2223
AaronBakerDev wants to merge 2 commits into
emdash-cms:mainfrom
AaronBakerDev:codex/scheduler-timezone-local-min

Conversation

@AaronBakerDev

@AaronBakerDev AaronBakerDev commented Jul 23, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes the scheduling control's datetime-local minimum so it is generated from the operator's local wall time instead of UTC wall time. Operators in negative UTC offsets can schedule content in the near future, while submission still converts the selected local value to the correct ISO instant. A Toronto UTC-4 regression covers browser validity and submitted conversion.

Closes #

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: OpenAI Codex (GPT-5)

Screenshots / test output

  • Focused ContentSettingsPanel tests: 19/19 passed.
  • File-scoped type-aware lint and formatting passed.
  • Package typecheck is currently blocked by an unrelated pre-existing RegistryPluginDetail implicit-any error outside this diff.
  • Includes a patch changeset for @emdash-cms/admin.

@changeset-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0db4000

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@emdash-cms/admin Patch
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/plugin-mcp-smoke Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the right change for the stated problem. The bug is real: <input type="datetime-local"> interprets min as local wall time, but the code was feeding it a UTC wall-time string, which pushed the effective minimum into the future for operators west of UTC. The fix — subtract the timezone offset and slice the local ISO string — is the standard, idiomatic trick for this input type, and the change is appropriately scoped to the admin panel.

I checked the component change, the new regression test, the changeset, and AGENTS.md conventions. There are no backend/SQL/API, authorization, i18n, or RTL concerns in this diff. The changeset is well written.

The one real issue is in the new test: the assertion about the submitted ISO string is tautological with respect to the timezone scenario it claims to cover. The mock of Date.prototype.getTimezoneOffset only affects formatDatetimeLocalValue, not the new Date(scheduleDate).toISOString() path used by handleScheduleSubmit, and the expected value is computed with that same new Date(string).toISOString() call in the test runner's host timezone. That means the assertion will pass even if the UTC conversion were wrong for a UTC-4 operator. The min attribute and checkValidity() assertions are meaningful; the onSchedule assertion here gives false confidence.

expect((scheduleInput.element() as HTMLInputElement).checkValidity()).toBe(true);

await screen.getByRole("button", { name: "Schedule" }).click();
expect(onSchedule).toHaveBeenCalledWith(new Date("2026-07-23T12:30").toISOString());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[needs fixing] This assertion claims to verify "submitted ISO conversion" for a UTC-4 operator, but it computes the expected value with the exact same new Date(string).toISOString() path the component uses, and the mocked getTimezoneOffset is never consulted by handleScheduleSubmit. The expected and actual values are therefore guaranteed to match in the test runner's host timezone regardless of whether the UTC conversion is correct for the mocked offset. The earlier min and checkValidity() assertions are the real regression test for this PR; this one is misleading. Drop the tautological toHaveBeenCalledWith assertion or replace it with a non-tautological check.

Suggested change
expect(onSchedule).toHaveBeenCalledWith(new Date("2026-07-23T12:30").toISOString());
await screen.getByRole("button", { name: "Schedule" }).click();
expect(onSchedule).toHaveBeenCalled();

@AaronBakerDev

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@AaronBakerDev

Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request Jul 23, 2026
@AaronBakerDev

Copy link
Copy Markdown
Author

Closing at the author's request. This upstream submission was opened without the repository owner's explicit approval.

@AaronBakerDev
AaronBakerDev deleted the codex/scheduler-timezone-local-min branch July 24, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant