Skip to content

Commit

Permalink
Merge pull request #4474 from emilecantin/fix-parse-options
Browse files Browse the repository at this point in the history
Fix options passed to date-fns/parse
  • Loading branch information
martijnrusschen authored Jan 27, 2024
2 parents 4535bc6 + 562b238 commit af0049b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/date_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ export function parseDate(value, dateFormat, locale, strictParsing, minDate) {
dateFormat.forEach((df) => {
let tryParseDate = parse(value, df, new Date(), {
locale: localeObject,
useAdditionalWeekYearTokens: true,
useAdditionalDayOfYearTokens: true,
});
if (strictParsing) {
strictParsingValueMatch =
Expand All @@ -95,7 +97,11 @@ export function parseDate(value, dateFormat, locale, strictParsing, minDate) {
return parsedDate;
}

parsedDate = parse(value, dateFormat, new Date(), { locale: localeObject });
parsedDate = parse(value, dateFormat, new Date(), {
locale: localeObject,
useAdditionalWeekYearTokens: true,
useAdditionalDayOfYearTokens: true,
});

if (strictParsing) {
strictParsingValueMatch =
Expand All @@ -117,7 +123,10 @@ export function parseDate(value, dateFormat, locale, strictParsing, minDate) {
.join("");

if (value.length > 0) {
parsedDate = parse(value, dateFormat.slice(0, value.length), new Date());
parsedDate = parse(value, dateFormat.slice(0, value.length), new Date(), {
useAdditionalWeekYearTokens: true,
useAdditionalDayOfYearTokens: true,
});
}

if (!isValid(parsedDate)) {
Expand Down

0 comments on commit af0049b

Please sign in to comment.