Bug 36341: (follow-up) Fix missing Date_from_syspref

It appears this bug introduces the first actual use of this function in
the OPAC and thus exposes that bug 31261 didn't fully port the
Date_from_syspref from the intranet.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 04d3cf07a8)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Martin Renvoize 2024-04-29 09:38:02 +01:00 committed by Fridolin Somers
parent 70219dd7b4
commit ab7a3ff196

View file

@ -136,6 +136,28 @@
}
}
function Date_from_syspref(dstring) {
var dateX = dstring.split(/[-/.]/);
if (debug > 1 && sentmsg < 1) {
sentmsg++;
alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));
}
if (dateformat_pref === "iso") {
return new Date(dateX[0], (dateX[1] - 1), dateX[2]); // YYYY-MM-DD to (YYYY,m(0-11),d)
} else if (dateformat_pref === "us") {
return new Date(dateX[2], (dateX[0] - 1), dateX[1]); // MM/DD/YYYY to (YYYY,m(0-11),d)
} else if (dateformat_pref === "metric") {
return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD/MM/YYYY to (YYYY,m(0-11),d)
} else if (dateformat_pref === "dmydot") {
return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD.MM.YYYY to (YYYY,m(0-11),d)
} else {
if (debug > 0) {
alert("KOHA ERROR - Unrecognized date format: " + dateformat_pref);
}
return 0;
}
}
$(document).ready(function(){
$(".flatpickr").each(function(){
let options = {};