Skip to content

feat(form): native date, time and date-time fields - #680

Open
kozmaadrian wants to merge 5 commits into
mainfrom
formdate
Open

feat(form): native date, time and date-time fields#680
kozmaadrian wants to merge 5 commits into
mainfrom
formdate

Conversation

@kozmaadrian

@kozmaadrian kozmaadrian commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

TODO

  • Release the da-sc-sdk with date/time format validation PR and re-vendor the published version — this PR currently vendors a dev build of the SDK in nx/deps/da-sc-sdk/dist/. The SDK source changes (format extraction, value-shape validation, docs) live on a separate da-sc-sdk branch.

Summary

Adds native date, time, and date-time field support to the SC form editor, driven entirely by the JSON Schema format keyword. A single form-date component wraps the browser's native <input> (date / time / datetime-local), so authors get real pickers and keyboard entry — including on mobile — instead of a plain text box.

Test URL: https://da.live/form?nx=formdate#/exp-workspace/frescopa/forms/date-input-test

Before: the time, date, and date-time inputs are simply text inputs.

Screenshot 2026-08-20 at 11 00 40 am

After: the time, date, and date-time fields use native HTML input elements.

format: date (floating date)
Screenshot 2026-08-20 at 10 59 58 am

format: date-time (the UI displays the users local time, however saves the same time in UTC always)
Screenshot 2026-08-20 at 11 00 08 am

format: time (float time, no timezone)
Screenshot 2026-08-20 at 11 00 18 am

How it works

The editor maps the schema format to one parameterized component:

schema format native input stored value
date date YYYY-MM-DD (floating, no timezone)
time time HH:MM (floating, no timezone)
date-time datetime-local YYYY-MM-DDTHH:MM:00Z (absolute instant, UTC)
  • date / time are floating — they mean the same everywhere (a publish date, store opening hours).
  • date-time is store-UTC / display-local — the picker shows and edits the value in the viewer's local zone and converts back to UTC on save, so the instant stays stable no matter which zone an author edits from.

Validation

Validation is owned by the SDK (the trust boundary — a script writing directly can't bypass it), not the widget:

  • date / time are checked for real calendar/clock validity (2026-02-30, 24:00 are rejected).
  • date-time is deliberately stricter than RFC 3339: only UTC Z with zero seconds is accepted, so the editor and any SDK-only writer produce one identical, comparable value (offsets, non-zero seconds, and sub-minute precision are rejected).
  • Empty optional fields are treated as absent — format is not enforced on an empty value.

Edge cases

  • Pre-1900 dates carry sub-minute Local Mean Time offsets; the local→UTC conversion rounds to the minute so those can't leak seconds and break the canonical form.
  • Early-CE years are zero-padded to 4 digits; the native year field is capped to 4 digits (some browsers otherwise allow 6).

Compatibility

  • Additive for any schema that doesn't use these formats — nothing changes.
  • Schemas that already declare format: date | time | date-time now render as pickers and get validated. Existing documents whose values aren't canonical (especially date-times with an offset or non-zero seconds) would surface a validation error, so it's worth a quick audit of existing date-time data. Validation is not gated on save, so this surfaces an error rather than blocking.

Testing

  • Unit tests for the widget, the local↔UTC helpers, and the editor dispatch, verified across time zones (incl. Europe/Zurich and America/New_York, which exercise the LMT edge). Full suite green.

Single form-date component parameterized by type, wrapping a native
<input> (date / time / datetime-local). Stores date as YYYY-MM-DD and
time as HH:MM (floating), and date-time as canonical UTC (...:00Z),
converting the author's local wall-clock to UTC on save and back to the
viewer's local zone on load. Minute-rounds to keep pre-1900 (Local Mean
Time) values canonical, and 4-digit-pads early-CE years.
Map schema format (date | time | date-time) to the form-date widget
type, and add form-date to the editor's field-spacing rules so date
fields align with the other fields.
@aem-code-sync

aem-code-sync Bot commented Aug 20, 2026

Copy link
Copy Markdown

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-sync branch
Commits

@kozmaadrian kozmaadrian changed the title DRAFT feat(form): add native date, time and date-time field feat(form): native date, time and date-time fields Aug 20, 2026
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.

1 participant