From 3328b64c21a1c4edcb5bda0bfecc1a89abd48f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?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"). --- 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 9fd0ea5..9b6dd52 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 53dae71..36d0d01 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 e831487..9b4f19e 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 67165e0..971f96c 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" || 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" || 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 a005216..533217f 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 1aea801..109aa7c 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 { -- 1.7.10.4