angular / angular/components

bug(DatePicker): Typing a date in "YYYY-MM-DD" format will format the date to "M/D/YYYY" but a day behind

Open
#27,412 8 comments 0 reactions 0 assignees View on GitHub
area: material/datepicker help wanted P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Typing a date in "YYYY-MM-DD" format will format the date to "M/D/YYYY" but a day behind. This occurs using the control in various modes, including the date range picker.

### Reproduction

Steps to reproduce (can use demo on documentation page):
1. Render date picker with default formatting.
2. Type in the value "2023-07-06"
3. Lose focus of the input field.
4. The date picker changes the value to: "7/5/2023"

### Expected Behavior

I expect to see the date represented in a different format with the same date value.

Value entered: 2023-07-06
Expected result: 7/6/2023

### Actual Behavior

The date in the proper format, but one day behind.

Value entered: 2023-07-06
Actual result: 7/5/2023

### Environment

This bug occurs on the demo page for angular material:
https://material.angular.io/components/datepicker/overview

- Angular: v14+
- CDK/Material: v14+ (probably earlier)
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows

Contributor guide

Open the contributing guide

Research direction

Start with the Angular Material datepicker demo at material.angular.io and reproduce the YYYY-MM-DD input losing focus in the default and date-range modes. Trace the datepicker input parsing and formatting path, then verify that 2023-07-06 is displayed as 7/6/2023 rather than 7/5/2023 without changing the underlying date value.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.