Summary: | Searching by DOB still broken in 22.05.x | ||
---|---|---|---|
Product: | Koha | Reporter: | Lucas Gass (lukeg) <lucas> |
Component: | Patrons | Assignee: | Jonathan Druart <jonathan.druart> |
Status: | CLOSED FIXED | QA Contact: | Marcel de Rooy <m.de.rooy> |
Severity: | normal | ||
Priority: | P5 - low | CC: | andrew, dcook, emily.lamancusa, gmcharlt, jonathan.druart, kyle.m.hall, m.de.rooy |
Version: | 22.05 | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | --- |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: | |||
Attachments: |
Bug 33132: Fix DOB search for 22.05
Bug 33132: [ALTERNATE] [22.05.x] Add date_to_rfc3339 Bug 33132: [22.05.x] Add date_to_rfc3339 |
Description
Lucas Gass (lukeg)
2023-03-03 20:22:33 UTC
Created attachment 147738 [details] [review] Bug 33132: Fix DOB search for 22.05 To test: 1. Apply patch 2. Search for patrons given their date of birth. You need to select "date of birth" in the "Search field" dropdown, or set it in DefaultPatronSearchFields. 3. Try with all the different dateformat's to make sure it works with each. With the patch applied, I still only find patrons when searching YYYY-MM-DD. Created attachment 151969 [details] [review] Bug 33132: [ALTERNATE] [22.05.x] Add date_to_rfc3339 Andrew, could you try this patch? Created attachment 152052 [details] [review] Bug 33132: [22.05.x] Add date_to_rfc3339 Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Applies to 22.05.x. Not tested. koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc: window.$date_to_rfc3339 = function(value, options) { koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc: let d = $date_to_rfc3339(pattern); window.$date_to_rfc3339 = function(value, options) { var dateformat = (options&&options.dateformat)||def_date_format; let m = moment(value, get_date_pattern(dateformat)); return m.format("YYYY-MM-DD"); } Just some observations, not blocking: Why do you have options if you do not use them? Why do you call get_date_pattern if you format YMD later on? Looks good to me for the rest. (In reply to Marcel de Rooy from comment #6) > Applies to 22.05.x. Not tested. > > koha-tmpl/intranet-tmpl/prog/en/includes/js-date-format.inc: > window.$date_to_rfc3339 = function(value, options) { > koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc: > let d = $date_to_rfc3339(pattern); > > window.$date_to_rfc3339 = function(value, options) { > var dateformat = (options&&options.dateformat)||def_date_format; > let m = moment(value, get_date_pattern(dateformat)); > return m.format("YYYY-MM-DD"); > } > > Just some observations, not blocking: > Why do you have options if you do not use them? This function has a bad and wrong history. This version is the one in master. options is there because it was there before, and it is consistent with the other function in the same file. > Why do you call get_date_pattern if you format YMD later on? > Looks good to me for the rest. You need to tell moment in which format is the string you are passing it. What we are doing is: let m = moment("20/06/2023", "DD/MM/YYYY"); // DD/MM/YYYY (indirectly) coming from dateformat m is a moment object you want to dispay the rfc3339/ymd version, and you ask moment to format it like that: m.format("YYYY-MM-DD") Does that make sense now? (In reply to Jonathan Druart from comment #7) > You need to tell moment in which format is the string you are passing it. > > What we are doing is: > let m = moment("20/06/2023", "DD/MM/YYYY"); // DD/MM/YYYY (indirectly) > coming from dateformat > m is a moment object > you want to dispay the rfc3339/ymd version, and you ask moment to format it > like that: > m.format("YYYY-MM-DD") > > Does that make sense now? Look at this code in the same file: window.$date = function(value, options) { if(!value) return ''; var tz = (options&&options.tz)||def_tz; var m = moment(value); Really, here we are just copying the code from master. All this needs to be rewritten, I agree with that. Why is this still here? Backported to 22.05.x for upcomoing 22.05.16. |