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

Paste into a DATE field allows invalid dates #138

Open
gtasker10 opened this issue Mar 1, 2023 · 0 comments
Open

Paste into a DATE field allows invalid dates #138

gtasker10 opened this issue Mar 1, 2023 · 0 comments

Comments

@gtasker10
Copy link

gtasker10 commented Mar 1, 2023

With jSuites 4, when pasting a value into a date field (or cell in jspreadsheet), invalid dates are allowed:

  • 2023-02-29
  • 2023-02-30
  • 2023-04-31

These result in an inaccurate date value being placed in the field/cell.

The problem is in this line:

 if (d[0] && d[1] && d[2] && d[0] > 0 && d[1] > 0 && d[1] < 13 && d[2] > 0 && d[2] < 32) {

this only checks that the DAY is 1-31. This code change fixes this by checking the DAY is <= the number of days in the specified MONTH:

 if (d[0] && d[1] && d[2] && d[0] > 0 && d[1] > 0 && d[1] < 13 && d[2] > 0 && d[2] <= new Date(d[0], d[1], 0).getDate()) {

I tried creating a pull request, but it says I don't have enough permission to do that

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

No branches or pull requests

1 participant