Bug 34292 - Date formatting in checkouts list broken
Summary: Date formatting in checkouts list broken
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on: 33804
Blocks:
  Show dependency treegraph
 
Reported: 2023-07-16 12:46 UTC by Katrin Fischer
Modified: 2023-12-28 20:47 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.11.00


Attachments
Bug 34292: Format the check out date with dt_from_string() (3.47 KB, patch)
2023-07-16 17:01 UTC, Andreas Roussos
Details | Diff | Splinter Review
Bug 34292: Fix typos in JSDoc documentation (2.04 KB, patch)
2023-07-16 17:01 UTC, Andreas Roussos
Details | Diff | Splinter Review
Bug 34292: (bug 33804 follow-up) Format "checked out on" date (1.57 KB, patch)
2023-07-17 08:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 34292: (bug 33804 follow-up) Format "checked out on" date (1.62 KB, patch)
2023-07-17 15:07 UTC, Andreas Roussos
Details | Diff | Splinter Review
Bug 34292: (bug 33804 follow-up) Format "checked out on" date (1.68 KB, patch)
2023-07-29 18:14 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 34292: (bug 33804 follow-up) Format "checked out on" date (2.21 KB, patch)
2023-07-29 18:15 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2023-07-16 12:46:31 UTC
I checked out an item and it showed the checkout date as:

2023-07-16 12:44:18

Dateformat was set to MM/DD/YYYY. Switching it to DD.MM.YYYY made no difference.

Due date displays correctly.
Comment 1 Andreas Roussos 2023-07-16 16:04:03 UTC
The relevant commit is 1000ab402b from Bug 33804, where the `mDataProp`
property of the "Checked out on" column was changed for both the issues
and the relatives' issues DataTables from "issuedate_formatted" to plain
"issuedate".

"issuedate" is retrieved (via svc/checkouts) from the `issues` database
table and is a datetime column of the form YYYY-MM-DD HH:MM:SS. This
explains the "2023-07-16 12:44:18" checkout date that Katrin observed.

"issuedate_formatted" comes from the same DB column, but is formatted
using Koha::DateUtils::dt_from_string() which takes into account the
`DateFormat` System Preference.
Comment 2 Andreas Roussos 2023-07-16 17:01:34 UTC
Created attachment 153523 [details] [review]
Bug 34292: Format the check out date with dt_from_string()

In the current master, checking out an item to a patron results
in a 'Checked out on' date of the form '2023-07-16 12:44:18'
when viewing the patron's 'Checkouts' table. This is due to commit
1000ab402b from Bug 33804 which changed the `mDataProp` property
of the 'Checked out on' column from "issuedate_formatted" to plain
"issuedate" (for both the issues and relatives' issues DataTables).

"issuedate" comes straight from the issues.issuedate DB column
(which has `datetime` format), whereas "issuedate_formatted" is
formatted using Koha::DateUtils::dt_from_string() which takes
into account the `dateformat` System Preference.

This patch restores the original behaviour w.r.t. the formatting
of the 'Checked out on' column.

Note: in `svc/checkouts` we don't pass `as_due_date => 1` for
`issuedate_formatted` because we *do* want to show a check out
date with a time component of 23:59.

Test plan:

1) Without applying this patch, issue an item to a patron and
   notice that in the 'Checkouts' table the 'Checked out on'
   date is of the form YYYY-MM-DD HH:MM:SS.

2) Apply this patch, restart Plack if necessary.

3) Refresh the patron 'Checkouts' table: this time the 'Checked
   out on' date will observe the setting of your `dateformat`
   System Preference.

4) Extra credit: repeat step 3) for different `dateformat`
   settings, each time you should get a 'Checked out on' date
   that matches the date format you chose.
Comment 3 Andreas Roussos 2023-07-16 17:01:37 UTC
Created attachment 153524 [details] [review]
Bug 34292: Fix typos in JSDoc documentation

equivilent -> equivalent
koha -> Koha
Comment 4 Jonathan Druart 2023-07-17 08:36:35 UTC
Created attachment 153526 [details] [review]
Bug 34292: (bug 33804 follow-up) Format "checked out on" date
Comment 5 Jonathan Druart 2023-07-17 08:37:51 UTC
Sorry about that! Thanks Andreas for the patches, however it is not correct to reinsert dt_from_string in the controller, we want to format date client-side.
This patch fixes the problem, however we should/could provide more cleaning and remove the "Sort on hidden unformatted issuedate column" related code as well (which could be done on a separate bug if needed).
Comment 6 Andreas Roussos 2023-07-17 15:06:23 UTC
Thank you for your feedback, Jonathan. I have now obsoleted my patch and only
kept the typo-fixing patch. I've also tested your patch and it works fine, so
I'm going to sign it off.
Comment 7 Andreas Roussos 2023-07-17 15:07:56 UTC
Created attachment 153559 [details] [review]
Bug 34292: (bug 33804 follow-up) Format "checked out on" date

Signed-off-by: Andreas Roussos <a.roussos@dataly.gr>
Comment 8 Jonathan Druart 2023-07-18 07:58:47 UTC
Thanks Andreas, could you adjust the status?
Comment 9 Andreas Roussos 2023-07-18 08:06:03 UTC
(In reply to Jonathan Druart from comment #8)
> Thanks Andreas, could you adjust the status?
Done! ;-)
Comment 10 Katrin Fischer 2023-07-29 18:14:48 UTC
Created attachment 154057 [details] [review]
Bug 34292: (bug 33804 follow-up) Format "checked out on" date

Signed-off-by: Andreas Roussos <a.roussos@dataly.gr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 11 Katrin Fischer 2023-07-29 18:15:17 UTC
Created attachment 154058 [details] [review]
Bug 34292: (bug 33804 follow-up) Format "checked out on" date

Test plan:

1) Without applying this patch, issue an item to a patron and
   notice that in the 'Checkouts' table the 'Checked out on'
   date is of the form YYYY-MM-DD HH:MM:SS.

2) Apply this patch, restart Plack if necessary.

3) Refresh the patron 'Checkouts' table: this time the 'Checked
   out on' date will observe the setting of your `dateformat`
   System Preference.

4) Extra credit: repeat step 3) for different `dateformat`
   settings, each time you should get a 'Checked out on' date
   that matches the date format you chose.

Signed-off-by: Andreas Roussos <a.roussos@dataly.gr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 12 Tomás Cohen Arazi 2023-08-15 09:14:02 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 13 Fridolin Somers 2023-08-17 19:52:07 UTC
Depends on Bug 33804 not in 23.05.x