Skip to content
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

fix: DatePicker issue observed when selecting date for icelandic language. #946

Merged

Conversation

harshith-venkatesh-freshworks
Copy link
Contributor

@harshith-venkatesh-freshworks harshith-venkatesh-freshworks commented Oct 29, 2024

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My commits have standard messages as mentioned in Contributing Guidelines

How Has This Been Tested?

version: 2.28.0
date-fns/locale = is

import { formatISO, parse } from 'date-fns';
import { is } from 'date-fns/locale';

const values = [
'12 jan. 2024',
'06 feb. 2024',
'06 mars 2024',
'17 apríl 2024',
'07 maí 2024',
'13 júní 2024',
'18 júlí 2024',
'04 sept. 2024',
'23 okt. 2024',
'15 nóv. 2024',
'04 des. 2024'
];

const formattedDates = values.map((value) => {
try {
const parsedDate = formatISO(
parse(value, 'dd MMMM yyyy', new Date(), { locale: is })
);
return parsedDate;
} catch (error) {
console.info(value, error);
}
});

console.log(formattedDates);

For the above code, we are observing the parsing is not occuring for the month sept. , okt. , nov., des.
We are observing the below error.

image

Stackblitz link for reference: https://stackblitz.com/edit/date-fns-bug-theqmk?file=package.json,index.ts

We are observing the same issue, even in the current version as well. 4.1.0
We have raised the PR with date-fns team to resolve this issue.
date-fns/date-fns#3934

This is a fix to resolve the date picker flow till our changes are merged.

Screenshot 2024-11-05 at 1 58 47 PM

@harshith-venkatesh-freshworks
Copy link
Contributor Author

https://github.com/date-fns/date-fns/blob/main/src/locale/is/snapshot.md
The above snapshot provides further details on which dateFormat leads to how many invalid dates, based on this we have chosen dd MMMM yyyy format for parsing purpose

Copy link
Collaborator

@rihansiddhi rihansiddhi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. please fix the checks

@rihansiddhi rihansiddhi merged commit f5e5084 into freshworks:next Nov 5, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants