Bug 28938 - Correct Flatpickr's default 12hr time formatting
Summary: Correct Flatpickr's default 12hr time formatting
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal (vote)
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on: 28928
Blocks: 28937 29239
  Show dependency treegraph
 
Reported: 2021-09-01 18:08 UTC by Owen Leonard
Modified: 2022-06-06 20:25 UTC (History)
3 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:
21.11.00


Attachments
Bug 28938: Correct Flatpickr's default 12hr time formatting (1.87 KB, patch)
2021-09-01 18:20 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 28938: Correct Flatpickr's default 12hr time formatting (1.95 KB, patch)
2021-09-02 06:50 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2021-09-01 18:08:27 UTC
In calendar.inc we define the variable "flatpickr_timeformat_string" using this string: "h:i K"

This results in times which don't include a leading zero (https://flatpickr.js.org/formatting/), a format which doesn't seem to be expected by the Perl script. It should be "G"

To reproduce: 

- Set the TimeFormat system preference to "12 hour"
- Find an item which is checked out and renewable.
- Go to Circulation -> Renew and use the date picker to select a time < 12, e.g. 9:00 AM
- Submit the barcode for renewal.
- Check the patron's account to see the due date: Instead of being due on your selected date at 9:00AM it will be due on your selected date at 12:00AM.
Comment 1 Owen Leonard 2021-09-01 18:20:22 UTC
Created attachment 124414 [details] [review]
Bug 28938: Correct Flatpickr's default 12hr time formatting

This patch corrects Flatpickr's default 12 time formatting so that it
uses the formatting token "G" ("Hours, 2 digits with leading zeros")
instead of "h" ("Hours, 2 digits without leading zeros").

This will prevent incorrect times from being saved when the submitted
time is before 12.

- To test, apply the patch go to Administration -> System preferences.
- Set the TimeFormat system preference to "12 hour"
- Find an item which is checked out and renewable.
- Go to Circulation -> Renew and use the date picker to select a time <
  12, e.g. 9:00 AM
- Submit the barcode for renewal.
- Check the patron's account to see the due date of the renewed item: It
  should match the date and time you selected.
Comment 2 Jonathan Druart 2021-09-02 06:50:42 UTC
Created attachment 124417 [details] [review]
Bug 28938: Correct Flatpickr's default 12hr time formatting

This patch corrects Flatpickr's default 12 time formatting so that it
uses the formatting token "G" ("Hours, 2 digits with leading zeros")
instead of "h" ("Hours, 2 digits without leading zeros").

This will prevent incorrect times from being saved when the submitted
time is before 12.

- To test, apply the patch go to Administration -> System preferences.
- Set the TimeFormat system preference to "12 hour"
- Find an item which is checked out and renewable.
- Go to Circulation -> Renew and use the date picker to select a time <
  12, e.g. 9:00 AM
- Submit the barcode for renewal.
- Check the patron's account to see the due date of the renewed item: It
  should match the date and time you selected.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 3 Jonathan Druart 2021-09-02 10:11:04 UTC
Pushed to master for 21.11, thanks to everybody involved!