Issue #1300 fix: fuzzydate strict date option regex #2354
No reviewers
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#2354
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "nandanv2702/issue_1300"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hey! This fix refers to issue #1300
I made changes to two of the files to include regex options to parse dates in the following formats:
All the aforementioned date formats use the separators
. or - or /
, e.g.:This can be activated using the strictDate option in the fuzzydate function which is set to
false
by default.Let me know whether this solution is what you were looking for!
ES6 issues aside (we are targeting ES3, so no const or default parameter values or arrow functions) two comments:
the result of the match is not used, so RegExp#test probably should be used. You might also be missing a new RegExp somewhere.
how should the library interpret something ambiguous like
03-02-01
or01/02/03
?Hey! I'll work on the changes for the first point soon, but as for the second - what do you think of including an option similar to
dateNF
that allows a user to enter the date format asdd-mm-yy, mm-dd-yy
etc.?Alternatively, if
strictDates
is set to true, we can usedateNF
(or the newly defined similar variable as mentioned above) to match any date values to the regex options defined in this PR hereWhat do you think?
Just following up on my last comment - after reading #2196 and #1646, I think it might make more sense to make the following changes:
strictDates
to a string that can bedd-mm
,mm-dd
, ortrue
STRICT_DATE_REGEX
to be an Object with the keysdd-mm
and `mm-dd with their respective regex valuesThis can allow for stricter dates while also letting us switch
dd-mm
tomm-dd
internally since the JS Date function only usesmm-dd
. In casestrictDates
istrue
, we can test it with allSTRICT_DATE_REGEX
values and return the first match (which will, by nature, be in themm-dd
format).I'm currently working on these changes, so let me know if this sounds good!
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Gitea.