Date picker min & max validations off by one day with local time zone behind UTC
Categories
(Core :: Layout: Form Controls, defect, P3)
Tracking
()
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.
| Assignee | ||
Comment 1•6 months ago
|
||
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.
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
| Assignee | ||
Comment 4•6 months ago
|
||
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
Updated•6 months ago
|
Comment 5•6 months ago
|
||
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
Updated•6 months ago
|
Updated•6 months ago
|
Updated•6 months ago
|
Comment 8•6 months ago
|
||
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.
| Assignee | ||
Comment 9•6 months ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM] from comment #6)
Can we come up with automated tests for this?
Yes, bug 2042274.
Description
•