Closed Bug 2040557 Opened 6 months ago Closed 6 months ago

Date picker min & max validations off by one day with local time zone behind UTC

Categories

(Core :: Layout: Form Controls, defect, P3)

Firefox 152
defect

Tracking

()

VERIFIED FIXED
153 Branch
Tracking Status
firefox152 --- verified
firefox153 --- verified

People

(Reporter: sam, Assigned: sam)

References

Details

Attachments

(2 external files)

data:text/html,<input type="date" min="2026-01-01" max="2027-01-01"/>

In my time zone, UTC-5, when opening the date picker from the above example and selecting the month/year dropdown, December 2025 is shown as enabled even though it is before the min date, and January 2027 is not shown even though it contains the max date.

In addition, setting the date as 2027-01-01 from the calendar does not work.

Date/time pickers have no time zone component, and the min/max date objects are created as UTC (midnight when no time component is provided). Therefore, the UTC representation should always be used. This fixes validation logic being off by one day when the local time zone is behind UTC.

Assignee: nobody → sam
Status: NEW → ASSIGNED
Depends on: 1728366, 1320647
Summary: Date picker validations off by one day with local time zone behind UTC → Date picker min & max validations off by one day with local time zone behind UTC
Severity: -- → S3
Priority: -- → P3
Pushed by sam@scj.me: https://github.com/mozilla-firefox/firefox/commit/8cae843401f1 https://hg.mozilla.org/integration/autoland/rev/2c6972821374 Always use UTC with date picker validations. r=layout-reviewers,hjones,dholbert
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 153 Branch

Date/time pickers have no time zone component, and the min/max date objects are created as UTC (midnight when no time component is provided). Therefore, the UTC representation should always be used. This fixes validation logic being off by one day when the local time zone is behind UTC.

Original Revision: https://phabricator.services.mozilla.com/D301230

Attachment #9588977 - Flags: approval-mozilla-beta?

firefox-beta Uplift Approval Request

  • User impact if declined/Reason for urgency: Certain valid dates will not be selectable from the date picker for <input type="date"/>
  • Code covered by automated testing?: no
  • Fix verified in Nightly?: no
  • Needs manual QE testing?: yes
  • Steps to reproduce for manual QE testing: On a machine with the timezone set to behind UTC: Open data:text/html,<input type="date" min="2026-01-01" max="2027-01-01"/>. Click inside the input to open the date picker, then attempt to select 1 January 2027. Also validate the available months and years in the dropdown match what is valid per the min and max values.
  • Risk associated with taking this patch: low
  • Explanation of risk level: Simple change to use UTC date functions instead of local date functions.
  • String changes made/needed?: None
  • Is Android affected?: no
Flags: qe-verify+

Can we come up with automated tests for this?

Flags: needinfo?(sam)
Attachment #9588977 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
QA Whiteboard: [uplift][qa-ver-needed-c153/b152]

I reproduced this issue with the info from comment 5 using an affected Nightly build (2026-05-18), on Win 11.

The issue is verified as fixed on latest Nightly 153.0a1 and Beta 152.0b3 with Win 11.

Status: RESOLVED → VERIFIED
QA Whiteboard: [uplift][qa-ver-needed-c153/b152] → [uplift][qa-ver-done-c153/b152]
Flags: qe-verify+
Blocks: 2042274

(In reply to Ryan VanderMeulen [:RyanVM] from comment #6)

Can we come up with automated tests for this?

Yes, bug 2042274.

Flags: needinfo?(sam)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: