Bug 5103 - Dates in MARC details not formatted correctly
Summary: Dates in MARC details not formatted correctly
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Aleisha Amohia
QA Contact: Bugs List
URL: /cgi-bin/koha/catalogue/MARCdetail.pl...
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-08 15:54 UTC by Katrin Fischer
Modified: 2020-04-14 23:49 UTC (History)
7 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: ---
Who signed the patch off:
Text to go in the release notes:
This fixes how dates are displayed for the list of items on the MARC view pages (in the OPAC and staff interface) and the add item page (staff interface) so that they use the 'dateformat' system preference.
Version(s) released in:
20.05.00, 19.11.05, 19.05.x


Attachments
Screenshot shows acq date in MARC details. (22.87 KB, image/png)
2010-08-08 15:54 UTC, Katrin Fischer
Details
Bug 5103: Format dates in MARC detail using dateformat syspref (5.11 KB, patch)
2020-02-26 02:58 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 5103: Format dates in MARC detail using dateformat syspref (5.13 KB, patch)
2020-02-26 18:17 UTC, David Nind
Details | Diff | Splinter Review
Bug 5103: (follow-up) Using mapped item fields instead of hardcoding subfields (3.91 KB, patch)
2020-03-11 03:09 UTC, Aleisha Amohia
Details | Diff | Splinter Review
Bug 5103: Format dates in MARC detail using dateformat syspref (5.18 KB, patch)
2020-03-11 10:54 UTC, David Nind
Details | Diff | Splinter Review
Bug 5103: (follow-up) Using mapped item fields instead of hardcoding subfields (3.97 KB, patch)
2020-03-11 10:54 UTC, David Nind
Details | Diff | Splinter Review
Bug 5103: Format dates in MARC detail using dateformat syspref (5.25 KB, patch)
2020-03-12 14:09 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 5103: (follow-up) Using mapped item fields instead of hardcoding subfields (4.04 KB, patch)
2020-03-12 14:09 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 5103: Refactor the code to avoid repetition (4.62 KB, patch)
2020-03-12 14:09 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 Katrin Fischer 2010-08-08 15:54:06 UTC
Created attachment 2483 [details]
Screenshot shows acq date in MARC details.

Date formats in catalogue > MARC > items are not formatted according to sys pref dateformat.

Tested with Koha version 3.01.00.145 and different settings for dateformat.
Comment 1 Owen Leonard 2010-08-09 19:44:53 UTC
This is true of the OPAC as well.

This is definitely not a template issue: The table of items is built very generically: 

<!-- TMPL_LOOP NAME="item_loop" -->
  <tr>
    <!-- TMPL_VAR NAME="item_value" -->
  </tr>
<!-- /TMPL_LOOP -->

And the script doesn't appear to have any means of knowing whether the data it's putting into that "item_loop" is a date or not. Wouldn't the script have to know which subfields contained dates?
Comment 2 Aleisha Amohia 2020-02-26 02:58:05 UTC
Created attachment 99627 [details] [review]
Bug 5103: Format dates in MARC detail using dateformat syspref

This patch fixes the formatting of dates on the following pages:
- catalogue/MARCdetail.pl (staff)
- cataloguing/additem.pl (staff)
- opac-MARCdetail.pl (opac)

To test:
1) Ensure that the following fields are visible in the opac, intranet
and editor. You may need to edit the subfields in your default
bibliographic framework
952$d date accessioned
952$q date due/on loan
952$r date last seen
952$s date last borrowed
952$w replacement price date

Also ensure you have dateformat system preference set

2) Go to cataloguing/additem.pl for a biblio. Fill in the fields above
if required. Save
3) Remain on cataloguing/additem.pl. Notice the items table at the top
of the page, the dates are in the generic yyyy-mm-dd format
4) Go to catalogue/MARCdetail.pl for that biblio. Notice dates in wrong
format
5) View this biblio in the opac opac-MARCdetail.pl. Scroll to bottom to
items table. Notice dates in wrong format.
6) Apply patch, restart memcached and plack and refresh pages
7) Dates should now be formatted according to dateformat preference
8) Confirm that changing the preference changes the format of the dates

Sponsored-by: Catalyst IT
Comment 3 David Nind 2020-02-26 18:17:38 UTC
Created attachment 99671 [details] [review]
Bug 5103: Format dates in MARC detail using dateformat syspref

This patch fixes the formatting of dates on the following pages:
- catalogue/MARCdetail.pl (staff)
- cataloguing/additem.pl (staff)
- opac-MARCdetail.pl (opac)

To test:
1) Ensure that the following fields are visible in the opac, intranet
and editor. You may need to edit the subfields in your default
bibliographic framework
952$d date accessioned
952$q date due/on loan
952$r date last seen
952$s date last borrowed
952$w replacement price date

Also ensure you have dateformat system preference set

2) Go to cataloguing/additem.pl for a biblio. Fill in the fields above
if required. Save
3) Remain on cataloguing/additem.pl. Notice the items table at the top
of the page, the dates are in the generic yyyy-mm-dd format
4) Go to catalogue/MARCdetail.pl for that biblio. Notice dates in wrong
format
5) View this biblio in the opac opac-MARCdetail.pl. Scroll to bottom to
items table. Notice dates in wrong format.
6) Apply patch, restart memcached and plack and refresh pages
7) Dates should now be formatted according to dateformat preference
8) Confirm that changing the preference changes the format of the dates

Sponsored-by: Catalyst IT
Comment 4 paxed 2020-02-27 08:17:43 UTC
The same if-block is repeated three times, in different files. This is very fragile and error prone. Should create a sub in one place (Koha::DateUtils maybe), and just call that instead.
Comment 5 Katrin Fischer 2020-02-29 19:52:59 UTC
Hi Aleisha,

I really love that you have taken on these old bugs!

Sadly, we got a UNIMARC vs MARC21 issue here - the mappings with UNIMARC are usually quite different. I think the best would be to look up the subfield codes with the known date columns we have in the items table instead of hardcoding the subfields - this way the MARC flavour and people having mapped things differently won't matter and it will always work.

As long as the code reads easily I am not that worried about repeating it at the moment, and it could be something to improve later on.
Comment 6 Aleisha Amohia 2020-03-11 03:09:43 UTC
Created attachment 100501 [details] [review]
Bug 5103: (follow-up) Using mapped item fields instead of hardcoding subfields
Comment 7 David Nind 2020-03-11 10:54:05 UTC
Created attachment 100527 [details] [review]
Bug 5103: Format dates in MARC detail using dateformat syspref

This patch fixes the formatting of dates on the following pages:
- catalogue/MARCdetail.pl (staff)
- cataloguing/additem.pl (staff)
- opac-MARCdetail.pl (opac)

To test:
1) Ensure that the following fields are visible in the opac, intranet
and editor. You may need to edit the subfields in your default
bibliographic framework
952$d date accessioned
952$q date due/on loan
952$r date last seen
952$s date last borrowed
952$w replacement price date

Also ensure you have dateformat system preference set

2) Go to cataloguing/additem.pl for a biblio. Fill in the fields above
if required. Save
3) Remain on cataloguing/additem.pl. Notice the items table at the top
of the page, the dates are in the generic yyyy-mm-dd format
4) Go to catalogue/MARCdetail.pl for that biblio. Notice dates in wrong
format
5) View this biblio in the opac opac-MARCdetail.pl. Scroll to bottom to
items table. Notice dates in wrong format.
6) Apply patch, restart memcached and plack and refresh pages
7) Dates should now be formatted according to dateformat preference
8) Confirm that changing the preference changes the format of the dates

Sponsored-by: Catalyst IT

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2020-03-11 10:54:09 UTC
Created attachment 100528 [details] [review]
Bug 5103: (follow-up) Using mapped item fields instead of hardcoding subfields

Signed-off-by: David Nind <david@davidnind.com>
Comment 9 Jonathan Druart 2020-03-12 14:09:27 UTC
Created attachment 100636 [details] [review]
Bug 5103: Format dates in MARC detail using dateformat syspref

This patch fixes the formatting of dates on the following pages:
- catalogue/MARCdetail.pl (staff)
- cataloguing/additem.pl (staff)
- opac-MARCdetail.pl (opac)

To test:
1) Ensure that the following fields are visible in the opac, intranet
and editor. You may need to edit the subfields in your default
bibliographic framework
952$d date accessioned
952$q date due/on loan
952$r date last seen
952$s date last borrowed
952$w replacement price date

Also ensure you have dateformat system preference set

2) Go to cataloguing/additem.pl for a biblio. Fill in the fields above
if required. Save
3) Remain on cataloguing/additem.pl. Notice the items table at the top
of the page, the dates are in the generic yyyy-mm-dd format
4) Go to catalogue/MARCdetail.pl for that biblio. Notice dates in wrong
format
5) View this biblio in the opac opac-MARCdetail.pl. Scroll to bottom to
items table. Notice dates in wrong format.
6) Apply patch, restart memcached and plack and refresh pages
7) Dates should now be formatted according to dateformat preference
8) Confirm that changing the preference changes the format of the dates

Sponsored-by: Catalyst IT

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 10 Jonathan Druart 2020-03-12 14:09:30 UTC
Created attachment 100637 [details] [review]
Bug 5103: (follow-up) Using mapped item fields instead of hardcoding subfields

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 11 Jonathan Druart 2020-03-12 14:09:34 UTC
Created attachment 100638 [details] [review]
Bug 5103: Refactor the code to avoid repetition

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 12 Martin Renvoize 2020-03-16 11:02:58 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 13 Joy Nelson 2020-04-03 17:35:40 UTC
Backported to 19.11.x branch for 19.11.05
Comment 14 Lucas Gass 2020-04-10 15:54:54 UTC
backported to 19.05.x for 19.05.10
Comment 15 Hayley Mapley 2020-04-14 23:49:09 UTC
Minor/enhancement will not be backported to 18.11.x series