From 0adbda80344b5cc828fcedea7d706073381f4605 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marc=20V=C3=A9ron?= Date: Wed, 18 Nov 2015 17:33:33 +0100 Subject: [PATCH] Bug 12072: Make datepicker and templates to be aware of dmydot format This patch is to display corrextly the new dmydot date format e.g. after using the datepicker or in messages for the user, in following files: - koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc - koha-tmpl/intranet-tmpl/prog/en/includes/date-format.inc - koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc - koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt - koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc - tools/holidays.pl To test: - Apply patch - Make sure that you have syspref dateformat set to dmydot - Use datepicker in OPAC (modify birth date), verify that after choosing a date, it is displayed correctly in the datepicker - Use datepicker at several places in OPAC, verify that after choosing a date the date displays properly in datepicker and that the dater format is properly indicated (e.g. near birth date or near "Specify due date"). - Verify that datepicker works well with hoiday editing and that "From date:" displays properly Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 6 ++++-- koha-tmpl/intranet-tmpl/prog/en/includes/date-format.inc | 2 +- koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc | 2 ++ koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt | 4 ++-- koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc | 6 ++++-- tools/holidays.pl | 5 ++++- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 9fd0ea5f57..9b6dd5223a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -8,7 +8,7 @@ var sentmsg = 0; if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");} function Date_from_syspref(dstring) { - var dateX = dstring.split(/[-/]/); + var dateX = dstring.split(/[-/.]/); if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));} if (dformat === "iso") { return new Date(dateX[0], (dateX[1] - 1), dateX[2]); // YYYY-MM-DD to (YYYY,m(0-11),d) @@ -16,6 +16,8 @@ function Date_from_syspref(dstring) { return new Date(dateX[2], (dateX[0] - 1), dateX[1]); // MM/DD/YYYY to (YYYY,m(0-11),d) } else if (dformat === "metric") { return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD/MM/YYYY to (YYYY,m(0-11),d) + } else if (dformat === "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: " +dformat);} return 0; @@ -66,7 +68,7 @@ jQuery(function($){ dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")], dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")], weekHeader: _("Wk"), - dateFormat: "[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]", + dateFormat: "[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSIF ( dateformat == "dmydot" ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]", firstDay: [% Koha.Preference('CalendarFirstDayOfWeek') %], isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %], showMonthAfterYear: false, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/date-format.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/date-format.inc index 53dae716a8..36d0d01461 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/date-format.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/date-format.inc @@ -1 +1 @@ -[% IF ( dateformat == "us" ) %](MM/DD/YYYY)[% ELSIF ( dateformat == "metric" ) %](DD/MM/YYYY)[% ELSE %](YYYY-MM-DD)[% END %] +[% IF ( dateformat == "us" ) %](MM/DD/YYYY)[% ELSIF ( dateformat == "metric" ) %](DD/MM/YYYY)[% ELSIF ( dateformat == "dmydot" ) %](DD.MM.YYYY)[% ELSE %](YYYY-MM-DD)[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index e831487e12..9b4f19e543 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -160,6 +160,8 @@ $(document).ready(function() { var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'YYYY-MM-DD'"); [% ELSIF dateformat == 'metric' %] var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD/MM/YYYY'"); + [% ELSIF dateformat == 'dmydot' %] + var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD.MM.YYYY'"); [% END %] $('#searchmember').attr("title",MSG_DATE_FORMAT).tooltip('show'); } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt index 67165e0c52..4f77b04227 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt @@ -260,7 +260,7 @@ td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl From date: , - [% IF ( dateformat == "us" ) %]//[% ELSIF ( dateformat == "metric" ) %]//[% ELSE %]//[% END %] + [% IF ( dateformat == "us" ) %]//[% ELSIF ( dateformat == "metric") %]//[% ELSIF ( dateformat == "dmydot") %]..[% ELSE %]//[% END %] @@ -331,7 +331,7 @@ td.repeatableyearly a.ui-state-default { background: #FFCC66 none; color : Bl From date: , - [% IF ( dateformat == "us" ) %]//[% ELSIF ( dateformat == "metric" ) %]//[% ELSE %]//[% END %] + [% IF ( dateformat == "us" ) %]//[% ELSIF ( dateformat == "metric" ) %]//[% ELSIF ( dateformat == "dmydot" ) %]..[% ELSE %]//[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc index a005216f4f..533217f5ae 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc @@ -7,7 +7,7 @@ if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");} function Date_from_syspref(dstring) { - var dateX = dstring.split(/[-/]/); + var dateX = dstring.split(/[-/.]/); if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));} if (dformat === "iso") { return new Date(dateX[0], (dateX[1] - 1), dateX[2]); // YYYY-MM-DD to (YYYY,m(0-11),d) @@ -15,6 +15,8 @@ return new Date(dateX[2], (dateX[0] - 1), dateX[1]); // MM/DD/YYYY to (YYYY,m(0-11),d) } else if (dformat === "metric") { return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD/MM/YYYY to (YYYY,m(0-11),d) + } else if (dformat === "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: " +dformat);} return 0; @@ -37,7 +39,7 @@ dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")], dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")], weekHeader: _("Wk"), - dateFormat: '[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]', + dateFormat: '[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSIF ( dateformat == "dmydot" ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]', firstDay: [% Koha.Preference('CalendarFirstDayOfWeek') %], isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %], showMonthAfterYear: false, diff --git a/tools/holidays.pl b/tools/holidays.pl index 1aea801b54..109aa7c1b2 100755 --- a/tools/holidays.pl +++ b/tools/holidays.pl @@ -99,7 +99,10 @@ foreach my $monthDay (keys %$day_month_holidays) { if (C4::Context->preference("dateformat") eq "metric") { $day_monthdate_sort = "$day_month_holidays->{$monthDay}{month}-$day_month_holidays->{$monthDay}{day}"; $day_monthdate = "$day_month_holidays->{$monthDay}{day}/$day_month_holidays->{$monthDay}{month}"; - } elsif (C4::Context->preference("dateformat") eq "us") { + } elsif (C4::Context->preference("dateformat") eq "dmydot") { + $day_monthdate_sort = "$day_month_holidays->{$monthDay}{month}.$day_month_holidays->{$monthDay}{day}"; + $day_monthdate = "$day_month_holidays->{$monthDay}{day}.$day_month_holidays->{$monthDay}{month}"; + }elsif (C4::Context->preference("dateformat") eq "us") { $day_monthdate = "$day_month_holidays->{$monthDay}{month}/$day_month_holidays->{$monthDay}{day}"; $day_monthdate_sort = $day_monthdate; } else { -- 2.39.5