Bug 31149 - Use dayjs to parse dates
Summary: Use dayjs to parse dates
Status: RESOLVED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact: Martin Renvoize (ashimema)
URL:
Keywords: additional_work_needed
Depends on: 30310
Blocks:
  Show dependency treegraph
 
Reported: 2022-07-13 07:04 UTC by Jonathan Druart
Modified: 2025-10-21 09:23 UTC (History)
5 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.11.00
Circulation function:


Attachments
Bug 31149: Use dayjs to parse dates (3.67 KB, patch)
2022-07-13 07:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 31149: Use dayjs to parse dates (3.76 KB, patch)
2022-12-16 14:13 UTC, Paul Derscheid
Details | Diff | Splinter Review
Bug 31149: Use dayjs to parse dates (3.81 KB, patch)
2022-12-20 12:56 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 31149: Use dayjs to parse dates (3.75 KB, patch)
2025-10-07 09:52 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 31149: Use dayjs to parse dates (3.81 KB, patch)
2025-10-10 13:12 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 31149: Add dayjs plugins (1.79 KB, patch)
2025-10-16 09:30 UTC, Pedro Amorim
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2022-07-13 07:04:42 UTC
We don't need our own JS functions to parse date, we can rely on dayjs for that.
Comment 1 Jonathan Druart 2022-07-13 07:08:18 UTC
Created attachment 137680 [details] [review]
Bug 31149: Use dayjs to parse dates

We can use the isValid's dayjs function instead of our own parsing
functions.

Test plan:
Confirm that you cannot enter an invalid date when using a date picker widget.
Comment 2 Paul Derscheid 2022-12-16 14:13:20 UTC
Created attachment 144680 [details] [review]
Bug 31149: Use dayjs to parse dates

We can use the isValid's dayjs function instead of our own parsing
functions.

Test plan:
Confirm that you cannot enter an invalid date when using a date picker widget.

Works as expected.

Signed-off-by: LMSCloudPaulD <paul.derscheid@lmscloud.de>
Comment 3 Martin Renvoize (ashimema) 2022-12-20 12:56:06 UTC
Created attachment 144733 [details] [review]
Bug 31149: Use dayjs to parse dates

We can use the isValid's dayjs function instead of our own parsing
functions.

Test plan:
Confirm that you cannot enter an invalid date when using a date picker widget.

Works as expected.

Signed-off-by: LMSCloudPaulD <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize (ashimema) 2022-12-20 12:56:49 UTC
This would be a PQA from me.. but we're blocked so marking as such.
Comment 5 Jonathan Druart 2025-10-07 09:52:39 UTC
Created attachment 187511 [details] [review]
Bug 31149: Use dayjs to parse dates

We can use the isValid's dayjs function instead of our own parsing
functions.

Test plan:
Confirm that you cannot enter an invalid date when using a date picker widget.

Works as expected.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 6 Jonathan Druart 2025-10-07 09:52:58 UTC
This one got lost!
Comment 7 Lucas Gass (lukeg) 2025-10-10 13:11:34 UTC
It seems like calendar.js is not tidy
Comment 8 Lucas Gass (lukeg) 2025-10-10 13:12:13 UTC
Created attachment 187734 [details] [review]
Bug 31149: Use dayjs to parse dates

We can use the isValid's dayjs function instead of our own parsing
functions.

Test plan:
Confirm that you cannot enter an invalid date when using a date picker widget.

Works as expected.

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Lucas Gass (lukeg) 2025-10-14 20:55:56 UTC
Nice work everyone!

Pushed to main for 25.11
Comment 10 Pedro Amorim 2025-10-16 09:23:08 UTC
This has broken the ILL list table, if it affects other tables, I don't know.
Create an ILL request and visit the table, you get this:

Uncaught TypeError: m.tz is not a function
    at window.$date (ill-requests.pl:1606:23)
    at render (ill-list-table_25.0600022.js:452:32)
    at Object._render (datatables.min_25.0600022.js:41:12213)
    at r.fnGetData (datatables.min_25.0600022.js:41:14938)

Reset to the previous commit:
git reset --hard 9f2216cf20584079bb3706b4d965d1e91e273016

Refresh, works fine.
Comment 11 Pedro Amorim 2025-10-16 09:30:42 UTC
Created attachment 187979 [details] [review]
Bug 31149: Add dayjs plugins

It seems dayjs is now being imported twice? With the second time overriding the first, but without the plugins.
This patch "fixes" the issue by proving this, but there is likely a better solution than this copy-paste from js-date-format.inc
Comment 12 Lucas Gass (lukeg) 2025-10-16 21:22:44 UTC
follow-up pushed to main
Comment 13 Jonathan Druart 2025-10-17 04:38:00 UTC
Lucas, please revert this. The code has changed since I originally wrote it. It was wrong to switch it back to SO without fully tested it.

I will have another look later, but I don't have time to deal with all the side-effects right now.

I suspect the Cypress tests to fail because of this.
You can also notice that flatpickr is broken right now ("Please enter a valid date (should match mm/dd/yyyy)")

Sorry about that!
Comment 14 Lucas Gass (lukeg) 2025-10-17 12:51:57 UTC
Reverted from main
Comment 15 Jonathan Druart 2025-10-21 09:23:48 UTC
I think this is no longer needed, see bug 41061.