Bugzilla – Attachment 27069 Details for
Bug 12072
New dateformat dd.mm.yyyy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12072 - New dateformat dd.mm.yyyy
Bug-12072---New-dateformat-ddmmyyyy.patch (text/plain), 17.09 KB, created by
Bernardo Gonzalez Kriegel
on 2014-04-14 04:36:06 UTC
(
hide
)
Description:
Bug 12072 - New dateformat dd.mm.yyyy
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2014-04-14 04:36:06 UTC
Size:
17.09 KB
patch
obsolete
>From a67b6cdc76392cf683a2277ad7970b58c9348530 Mon Sep 17 00:00:00 2001 >From: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Date: Sun, 13 Apr 2014 19:42:02 -0300 >Subject: [PATCH] Bug 12072 - New dateformat dd.mm.yyyy > >I changed bug description, not quite apropriate language. >Really, it's hard :( > >This patch adds dd.mm.yyyy format as requested. >For lack of a better name, I used 'dol', >for 'dot on the line' > >To test: >1. apply the patch >2. run updatedatabase.pl >3. go to Admin > Sysprefs > I18N, change dateformat to dd.mm.yyyy, save >4. Test. There are some places where dates are in iso format >by design (yyyy-mm-dd), others must shows new 'dol' format >Works for circulation, reserves, staff & opac, patrons... > >But... built-in offline shows correct format on datepicker, but not >on checked out items, have not discovered yet how this works. > >So, not ready for sign-off I suppose, but can be tested > >Resubmited, bad message on updatedatabase.pl >--- > C4/Dates.pm | 5 ++++- > Koha/DateUtils.pm | 10 ++++++++++ > installer/data/mysql/sysprefs.sql | 2 +- > installer/data/mysql/updatedatabase.pl | 9 +++++++++ > .../intranet-tmpl/prog/en/includes/calendar.inc | 8 ++++---- > .../intranet-tmpl/prog/en/includes/date-format.inc | 2 +- > .../prog/en/includes/patron-search.inc | 2 ++ > .../en/modules/admin/preferences/i18n_l10n.pref | 1 + > .../intranet-tmpl/prog/en/modules/circ/offline.tt | 2 +- > .../opac-tmpl/bootstrap/en/includes/calendar.inc | 8 ++++---- > .../bootstrap/en/includes/date-format.inc | 2 +- > koha-tmpl/opac-tmpl/prog/en/includes/calendar.inc | 6 +++--- > .../opac-tmpl/prog/en/includes/date-format.inc | 2 +- > 13 files changed, 42 insertions(+), 17 deletions(-) > >diff --git a/C4/Dates.pm b/C4/Dates.pm >index 4fd08ae..f1b51c7 100644 >--- a/C4/Dates.pm >+++ b/C4/Dates.pm >@@ -54,6 +54,7 @@ sub reset_prefformat { # subroutine to clear the prefformat, called when we cha > our %format_map = ( > iso => 'yyyy-mm-dd', # plus " HH:MM:SS" > metric => 'dd/mm/yyyy', # plus " HH:MM:SS" >+ dol => 'dd.mm.yyyy', > us => 'mm/dd/yyyy', # plus " HH:MM:SS" > sql => 'yyyymmdd HHMMSS', > rfc822 => 'a, dd b y HH:MM:SS z ', >@@ -61,6 +62,7 @@ our %format_map = ( > our %posix_map = ( > iso => '%Y-%m-%d', # or %F, "Full Date" > metric => '%d/%m/%Y', >+ dol => '%d.%m.%Y', > us => '%m/%d/%Y', > sql => '%Y%m%d %H%M%S', > rfc822 => '%a, %d %b %Y %H:%M:%S %z', >@@ -70,6 +72,7 @@ our %dmy_subs = ( # strings to eval (after using regular ex > # make arrays for POSIX::strftime() > iso => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]', > metric => '[(($6||0),($5||0),($4||0),$1, $2 - 1, $3 - 1900)]', >+ dol => '[(($6||0),($5||0),($4||0),$1, $2 - 1, $3 - 1900)]', > us => '[(($6||0),($5||0),($4||0),$2, $1 - 1, $3 - 1900)]', > sql => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]', > rfc822 => '[($7, $6, $5, $2, $3, $4 - 1900, $8)]', >@@ -81,7 +84,7 @@ our @days = qw(Sun Mon Tue Wed Thu Fri Sat); > > sub regexp ($;$) { > my $self = shift; >- my $delim = qr/:?\:|\/|-/; # "non memory" cluster: no backreference >+ my $delim = qr/:?\:|\/|-|\./; # "non memory" cluster: no backreference > my $format = (@_) ? _recognize_format(shift) : ( $self->{'dateformat'} || _prefformat() ); > > # Extra layer of checking $self->{'dateformat'}. >diff --git a/Koha/DateUtils.pm b/Koha/DateUtils.pm >index ea57778..c641971 100644 >--- a/Koha/DateUtils.pm >+++ b/Koha/DateUtils.pm >@@ -68,6 +68,11 @@ sub dt_from_string { > $date_string =~ s#-#/#g; > $date_string =~ s/^00/01/; # system allows the 0th of the month > $date_string =~ s#^(\d{1,2})/(\d{1,2})#$2/$1#; >+ } >+ elsif ( $date_format eq 'dol' ) { >+ $date_string =~ s#\.#/#g; >+ $date_string =~ s/^00/01/; # system allows the 0th of the month >+ $date_string =~ s#^(\d{1,2})/(\d{1,2})#$2/$1#; > } else { > if ( $date_format eq 'iso' ) { > $date_string =~ s/-00/-01/; >@@ -140,6 +145,11 @@ sub output_pref { > ? $dt->strftime("%d/%m/%Y") > : $dt->strftime("%d/%m/%Y $time"); > } >+ elsif ( $pref =~ m/^dol/ ) { >+ return $dateonly >+ ? $dt->strftime("%d.%m.%Y") >+ : $dt->strftime("%d.%m.%Y $time"); >+ } > elsif ( $pref =~ m/^us/ ) { > > return $dateonly >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 661910b..63ebbc2 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -83,7 +83,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page. NOTE: this can slow down search response time significantly','YesNo'), > ('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'), > ('CurrencyFormat','US','US|FR','Determines the display format of currencies. eg: \'36000\' is displayed as \'360 000,00\' in \'FR\' or \'360,000.00\' in \'US\'.','Choice'), >-('dateformat','us','metric|us|iso','Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd)','Choice'), >+('dateformat','us','metric|us|iso|dol','Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd, Dot on the line dd.mm.yyyy)','Choice'), > ('DebugLevel','2','0|1|2','Define the level of debugging information sent to the browser when errors are encountered (set to 0 in production). 0=none, 1=some, 2=most','Choice'), > ('decreaseLoanHighHolds',NULL,'','Decreases the loan period for items with number of holds above the threshold specified in decreaseLoanHighHoldsValue','YesNo'), > ('decreaseLoanHighHoldsDuration',NULL,'','Specifies a number of days that a loan is reduced to when used in conjunction with decreaseLoanHighHolds','Integer'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 194df7d..6f4ecc1 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8106,6 +8106,15 @@ if(CheckVersion($DBversion)) { > SetVersion($DBversion); > } > >+$DBversion = "3.15.00.XXX"; >+if(CheckVersion($DBversion)) { >+ $dbh->do(q{ >+ UPDATE systempreferences SET options = 'metric|us|iso|dol', explanation = 'Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd, Dot on the line dd.mm.yyyy)' WHERE variable = 'dateformat' >+ }); >+ print "Upgrade to $DBversion done (Bug 12072 - New dateformat dd.mm.yyyy)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >index 1337044..db018e6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -7,14 +7,14 @@ 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) > } else if (dformat === "us") { > 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 === "metric" || dformat === "dol") { >+ return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD/MM/YYYY or DD.MM.YYYY to (YYYY,m(0-11),d) > } else { > if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);} > return 0; >@@ -37,7 +37,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 == "dol" ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]", > firstDay: [% 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..668189b 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 == "dol" ) %](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 bccd39c..82a4957 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -33,6 +33,8 @@ > 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 == 'dol' %] >+ 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/admin/preferences/i18n_l10n.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref >index 02985d3..379f0c0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref >@@ -6,6 +6,7 @@ I18N/L10N: > choices: > us: mm/dd/yyyy > metric: dd/mm/yyyy >+ dol: dd.mm.yyyy > iso: yyyy-mm-dd > - . > - >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt >index 49f443e..da2e0ef 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt >@@ -37,7 +37,7 @@ var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in t > > var start; > >-var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]'; >+var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSIF ( dateformat_dol ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]'; > > function checkin(barcode, item, error) { > var alerts = checkAlerts(barcode, item); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc >index 4280540..c041b6a 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc >@@ -6,14 +6,14 @@ > 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) > } else if (dformat === "us") { > 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 === "metric" || dformat === "dol") { >+ return new Date(dateX[2], (dateX[1] - 1), dateX[0]); // DD/MM/YYYY or DD.MM.YYYY to (YYYY,m(0-11),d) > } else { > if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);} > return 0; >@@ -36,7 +36,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 == "dol" ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]', > firstDay: [% CalendarFirstDayOfWeek %], > isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %], > showMonthAfterYear: false, >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/date-format.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/date-format.inc >index f651b74..9378568 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/date-format.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/date-format.inc >@@ -1 +1 @@ >-<span class="dateformat">[% IF ( dateformat == "us" ) %](MM/DD/YYYY)[% ELSIF ( dateformat == "metric" ) %](DD/MM/YYYY)[% ELSE %](YYYY-MM-DD)[% END %]</span> >+<span class="dateformat">[% IF ( dateformat == "us" ) %](MM/DD/YYYY)[% ELSIF ( dateformat == "metric" ) %](DD/MM/YYYY)[% ELSIF ( dateformat == "dol" ) %](DD.MM.YYYY)[% ELSE %](YYYY-MM-DD)[% END %]</span> >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/opac-tmpl/prog/en/includes/calendar.inc >index eb660d1..7600dd3 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/calendar.inc >@@ -7,13 +7,13 @@ 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) > } else if (dformat === "us") { > return new Date(dateX[2], (dateX[0] - 1), dateX[1]); // MM/DD/YYYY to (YYYY,m(0-11),d) >- } else if (dformat === "metric") { >+ } else if (dformat === "metric" || dformat === "dol") { > 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);} >@@ -37,7 +37,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 == "dol" ) %]dd.mm.yy[% ELSE %]yy-mm-dd[% END %]', > firstDay: [% CalendarFirstDayOfWeek %], > isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %], > showMonthAfterYear: false, >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/date-format.inc b/koha-tmpl/opac-tmpl/prog/en/includes/date-format.inc >index 53dae71..668189b 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/date-format.inc >+++ b/koha-tmpl/opac-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 == "dol" ) %](DD.MM.YYYY)[% ELSE %](YYYY-MM-DD)[% END %] >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12072
:
27068
|
27069
|
27082
|
27107
|
27108
|
27109
|
27118
|
27130
|
36726
|
36761
|
43317
|
43318
|
44463
|
44606
|
44747
|
44964
|
44966
|
44980
|
45020
|
45022