Skip to content

Follow WordPress time format on submission forms [#300]#305

Merged
dgershman merged 2 commits into
mainfrom
feature/mayo-300-submission-12hour-time-format
Jul 9, 2026
Merged

Follow WordPress time format on submission forms [#300]#305
dgershman merged 2 commits into
mainfrom
feature/mayo-300-submission-12hour-time-format

Conversation

@dgershman

Copy link
Copy Markdown
Contributor

Closes #300

Problem

The event and announcement submission forms rendered Start/End time with a native <input type="time">. The displayed format of that element is dictated by the browser/OS locale, not by the plugin or WordPress — so on several sites it forced 24-hour ("military") time entry, which most US civilians find confusing. The value was always stored as canonical 24h HH:mm, and the Event Calendar / List / Post Edit already convert it to AM/PM for display — only the input side regressed.

Fix

  • Shared TimeField component (assets/js/src/components/public/TimeField.js) presents:

    • 12-hour: Hour (1–12) / Minute / AM–PM selects
    • 24-hour: Hour (0–23) / Minute selects (deterministic — no reliance on browser locale)

    It parses the incoming HH:mm value and always emits a canonical 24h HH:mm via a synthetic change event, so form storage and all downstream display are unchanged.

  • Server resolves the format (includes/Frontend.php): a new resolve_time_format() helper derives 12hour/24hour from the WordPress Settings → General → Time Format option by default, and both render_event_form and render_announcement_form pass it to JS. A new time_format="12hour|24hour" shortcode attribute can override per form.

  • Applied to both EventForm.js and AnnouncementForm.js (both had the same native-input bug).

Testing

  • npm run build compiles cleanly; php -l passes on Frontend.php.
  • Manual: with WP Time Format = 12-hour, the forms show Hour/Minute/AM-PM and 7:30 PM stores as 19:30 and displays as 7:30 PM. With 24-hour, forms show 0–23 hour + minute and round-trip the same value. [mayo_event_form time_format="24hour"] overrides the WP option.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RGXVGBiyvPyLCesFqS91d1

The event and announcement submission forms rendered Start/End time with a
native <input type="time">, whose display format is dictated by the browser/OS
locale rather than the site config. On some setups this forced 24-hour entry,
which most US civilians find confusing.

Add a shared TimeField React component that presents 12-hour (Hour/Minute/AM-PM)
or 24-hour (Hour/Minute) selects based on a resolved format, while always
emitting canonical HH:mm so storage and downstream display are unchanged. The
format is resolved server-side from the WordPress "Time Format" setting by
default and can be overridden per form via a new time_format shortcode option.

🐦‍⬛ Generated with Claude Code, orchestrated by Crow

Co-Authored-By: Claude <noreply@anthropic.com>
Crow-Session: F2C638F9-1488-416C-91D8-8924E2988AD6
Claude-Session: https://claude.ai/code/session_01RGXVGBiyvPyLCesFqS91d1
@dgershman dgershman force-pushed the feature/mayo-300-submission-12hour-time-format branch from cef40b2 to 125ac62 Compare July 9, 2026 23:10
render_event_form/render_announcement_form now read the WordPress "Time
Format" setting via resolve_time_format(), so the Frontend unit tests must
stub get_option. Add the mock in setUp so all form-render tests have it.

🐦‍⬛ Generated with Claude Code, orchestrated by Crow

Co-Authored-By: Claude <noreply@anthropic.com>
Crow-Session: F2C638F9-1488-416C-91D8-8924E2988AD6
Claude-Session: https://claude.ai/code/session_01RGXVGBiyvPyLCesFqS91d1
@dgershman dgershman merged commit a2d472d into main Jul 9, 2026
3 checks passed
@dgershman dgershman deleted the feature/mayo-300-submission-12hour-time-format branch July 9, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Submission Page does not follow Wordpress date config if set to 12hour - It only accepts 24hour format

1 participant