Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent weekday headers and grid dates when using date-fns with default locale #2509

Closed
daveallie opened this issue Oct 4, 2024 · 0 comments · Fixed by #2550
Closed

Comments

@daveallie
Copy link
Contributor

Code

import { DayPicker } from 'react-day-picker';
import { enAU } from 'date-fns/locale';
import * as dateFns from 'date-fns';

dateFns.setDefaultOptions({ locale: enAU });

export function App() {
  return <DayPicker dateLib={dateFns} mode='single' />;
}

Expected Behavior

I would expect the weekday column headers to correctly match up with the dates in the grid as pictured below:

Note: Friday 4th October 2024 is a correct date and appears in the two grids

locale explicitly set to enAU (locale={enAU}):
CleanShot 2024-10-04 at 14 48 48

locale explicitly set to enUS (locale={enUS}):
CleanShot 2024-10-04 at 14 50 18

Actual Behavior

When dateFns is supplied as the dateLib and has been setup with the default locale of enAU, the weekday headers render as enUS, but the grid renders as enAU, resulting in incorrect weekdays lining up with dates:

Note: Friday 5th October 2024 is not a correct date

CleanShot 2024-10-04 at 14 47 35

Repository owner locked and limited conversation to collaborators Oct 5, 2024
@gpbl gpbl converted this issue into discussion #2511 Oct 5, 2024
daveallie added a commit to daveallie/react-day-picker that referenced this issue Oct 8, 2024
daveallie added a commit to daveallie/react-day-picker that referenced this issue Oct 8, 2024
@gpbl gpbl linked a pull request Oct 23, 2024 that will close this issue

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
1 participant