Skip to content

Bug: DateTimeInput generates invalid HTML date values (0-indexed month) #566

@shantoislamdev

Description

@shantoislamdev

The DateTimeInput component in both Lit and Angular renderers incorrectly formats the date string for the underlying <input type="date"> element, using 0-indexed months (00-11) instead of the HTML-required 1-indexed format (01-12).

Bug Location

  • Lit: renderers/lit/src/0.8/ui/datetime-input.ts - Line: 137
  • Angular: renderers/angular/src/lib/catalog/datetime-input.ts - Line 97

Bug Details

When a date is passed to the component (e.g., January 15, 2025):

  1. The code calls date.getMonth(), which returns 0 for January.
  2. It constructs the string: 2025-00-15.
  3. It sets this as the value attribute of the input: <input type="date" value="2025-00-15">.
  4. Result: Browsers reject 00 as an invalid month and render an empty input.
// Current Code
const month = this.#padNumber(date.getMonth()); // Returns "00" for January

Impact

  • Functionality: Users cannot see pre-filled dates in January (and potentially other months depending on browser strictness).
  • Cross-Platform: Affects both Lit and Angular implementations equally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions