@@ -, +, @@
dmydot.
---
C4/Dates.pm | 15 ++++++++++++---
C4/Templates.pm | 1 +
Koha/DateUtils.pm | 9 +++++++++
installer/data/mysql/sysprefs.sql | 2 +-
installer/data/mysql/updatedatabase.pl | 10 ++++++++++
.../intranet-tmpl/prog/en/includes/calendar.inc | 16 ++--------------
.../intranet-tmpl/prog/en/includes/date-format.inc | 2 +-
.../prog/en/includes/patron-search.inc | 9 +--------
.../en/modules/admin/preferences/i18n_l10n.pref | 1 +
.../intranet-tmpl/prog/en/modules/circ/offline.tt | 2 +-
.../prog/en/modules/tools/holidays.tt | 8 ++------
.../opac-tmpl/bootstrap/en/includes/calendar.inc | 16 ++--------------
.../bootstrap/en/includes/date-format.inc | 2 +-
koha-tmpl/opac-tmpl/prog/en/includes/calendar.inc | 16 ++--------------
.../opac-tmpl/prog/en/includes/date-format.inc | 2 +-
tools/exceptionHolidays.pl | 19 +++++--------------
tools/newHolidays.pl | 18 +++++-------------
17 files changed, 57 insertions(+), 91 deletions(-)
--- a/C4/Dates.pm
+++ a/C4/Dates.pm
@@ -40,20 +40,21 @@ use vars qw($prefformat);
sub _prefformat {
unless ( defined $prefformat ) {
- $prefformat = C4::Context->preference('dateformat');
+ $prefformat = C4::Context->preference('dateformat') || 'us';
}
return $prefformat;
}
sub reset_prefformat { # subroutine to clear the prefformat, called when we change it
if (defined $prefformat){
- $prefformat = C4::Context->preference('dateformat');
+ $prefformat = C4::Context->preference('dateformat') || 'us';
}
}
our %format_map = (
iso => 'yyyy-mm-dd', # plus " HH:MM:SS"
metric => 'dd/mm/yyyy', # plus " HH:MM:SS"
+ dmydot => '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',
+ dmydot => '%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)]',
+ dmydot => '[(($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'}.
@@ -213,6 +216,12 @@ sub format { # get or set dateformat: iso, metric, us, etc.
$self->{'dateformat'} = _recognize_format(shift);
}
+# get format string, eg. "yyyy-mm-dd"
+sub formatstr {
+ my $self = shift;
+ return $format_map{$self->{'dateformat'}};
+}
+
sub visual {
my $self = shift;
if (@_) {
--- a/C4/Templates.pm
+++ a/C4/Templates.pm
@@ -112,6 +112,7 @@ sub output {
$vars->{opacsmallimage} = C4::Context->preference('opacsmallimage');
$vars->{opaclayoutstylesheet} =
C4::Context->preference('opaclayoutstylesheet');
+ $vars->{dateformatstyle} = C4::Dates->new()->formatstr();
# add variables set via param to $vars for processing
# and clean any utf8 mess
--- a/Koha/DateUtils.pm
+++ a/Koha/DateUtils.pm
@@ -68,6 +68,10 @@ 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 'dmydot' ) {
+ $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 +144,11 @@ sub output_pref {
? $dt->strftime("%d/%m/%Y")
: $dt->strftime("%d/%m/%Y $time");
}
+ elsif ( $pref =~ m/^dmydot/ ) {
+ return $dateonly
+ ? $dt->strftime("%d.%m.%Y")
+ : $dt->strftime("%d.%m.%Y $time");
+ }
elsif ( $pref =~ m/^us/ ) {
return $dateonly
--- a/installer/data/mysql/sysprefs.sql
+++ a/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|dmydot','Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd, dmydot 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'),
--- a/installer/data/mysql/updatedatabase.pl
+++ a/installer/data/mysql/updatedatabase.pl
@@ -8120,6 +8120,16 @@ if ( CheckVersion($DBversion) ) {
SetVersion($DBversion);
}
+$DBversion = "3.15.00.XXX";
+if(CheckVersion($DBversion)) {
+ $dbh->do(q{
+ UPDATE systempreferences SET options = 'metric|us|iso|dmydot', explanation = 'Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd, DMY separated by dots 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)
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
@@ -3,22 +3,10 @@
var debug = "[% debug %]";
var dformat = "[% dateformat %]";
-var sentmsg = 0;
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
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 (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 (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);}
- return 0;
- }
+ return $.datepicker.parseDate( "[% dateformatstyle | replace('yyyy', 'yy') %]", dstring );
}
/* Instead of including multiple localization files as you would normally see with
@@ -37,7 +25,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: "[% dateformatstyle | replace("yyyy", "yy") %]",
firstDay: [% CalendarFirstDayOfWeek %],
isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
showMonthAfterYear: false,
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/date-format.inc
+++ a/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 %]
+([% dateformatstyle | upper %])
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
+++ a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc
@@ -24,16 +24,9 @@