View | Details | Raw Unified | Return to bug 12072
Collapse All | Expand All

(-)a/C4/Dates.pm (-3 / +12 lines)
Lines 40-59 use vars qw($prefformat); Link Here
40
40
41
sub _prefformat {
41
sub _prefformat {
42
    unless ( defined $prefformat ) {
42
    unless ( defined $prefformat ) {
43
        $prefformat = C4::Context->preference('dateformat');
43
        $prefformat = C4::Context->preference('dateformat') || 'us';
44
    }
44
    }
45
    return $prefformat;
45
    return $prefformat;
46
}
46
}
47
47
48
sub reset_prefformat {  # subroutine to clear the prefformat, called when we change it
48
sub reset_prefformat {  # subroutine to clear the prefformat, called when we change it
49
    if (defined $prefformat){
49
    if (defined $prefformat){
50
	$prefformat = C4::Context->preference('dateformat');
50
	$prefformat = C4::Context->preference('dateformat') || 'us';
51
    }
51
    }
52
}
52
}
53
53
54
our %format_map = (
54
our %format_map = (
55
    iso    => 'yyyy-mm-dd',           # plus " HH:MM:SS"
55
    iso    => 'yyyy-mm-dd',           # plus " HH:MM:SS"
56
    metric => 'dd/mm/yyyy',           # plus " HH:MM:SS"
56
    metric => 'dd/mm/yyyy',           # plus " HH:MM:SS"
57
    dmydot => 'dd.mm.yyyy',
57
    us     => 'mm/dd/yyyy',           # plus " HH:MM:SS"
58
    us     => 'mm/dd/yyyy',           # plus " HH:MM:SS"
58
    sql    => 'yyyymmdd    HHMMSS',
59
    sql    => 'yyyymmdd    HHMMSS',
59
    rfc822 => 'a, dd b y HH:MM:SS z ',
60
    rfc822 => 'a, dd b y HH:MM:SS z ',
Lines 61-66 our %format_map = ( Link Here
61
our %posix_map = (
62
our %posix_map = (
62
    iso    => '%Y-%m-%d',             # or %F, "Full Date"
63
    iso    => '%Y-%m-%d',             # or %F, "Full Date"
63
    metric => '%d/%m/%Y',
64
    metric => '%d/%m/%Y',
65
    dmydot => '%d.%m.%Y',
64
    us     => '%m/%d/%Y',
66
    us     => '%m/%d/%Y',
65
    sql    => '%Y%m%d    %H%M%S',
67
    sql    => '%Y%m%d    %H%M%S',
66
    rfc822 => '%a, %d %b %Y %H:%M:%S %z',
68
    rfc822 => '%a, %d %b %Y %H:%M:%S %z',
Lines 70-75 our %dmy_subs = ( # strings to eval (after using regular ex Link Here
70
                                      # make arrays for POSIX::strftime()
72
                                      # make arrays for POSIX::strftime()
71
    iso    => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]',
73
    iso    => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]',
72
    metric => '[(($6||0),($5||0),($4||0),$1, $2 - 1, $3 - 1900)]',
74
    metric => '[(($6||0),($5||0),($4||0),$1, $2 - 1, $3 - 1900)]',
75
    dmydot => '[(($6||0),($5||0),($4||0),$1, $2 - 1, $3 - 1900)]',
73
    us     => '[(($6||0),($5||0),($4||0),$2, $1 - 1, $3 - 1900)]',
76
    us     => '[(($6||0),($5||0),($4||0),$2, $1 - 1, $3 - 1900)]',
74
    sql    => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]',
77
    sql    => '[(($6||0),($5||0),($4||0),$3, $2 - 1, $1 - 1900)]',
75
    rfc822 => '[($7, $6, $5, $2, $3, $4 - 1900, $8)]',
78
    rfc822 => '[($7, $6, $5, $2, $3, $4 - 1900, $8)]',
Lines 81-87 our @days = qw(Sun Mon Tue Wed Thu Fri Sat); Link Here
81
84
82
sub regexp ($;$) {
85
sub regexp ($;$) {
83
    my $self   = shift;
86
    my $self   = shift;
84
    my $delim  = qr/:?\:|\/|-/;                                                                  # "non memory" cluster: no backreference
87
    my $delim  = qr/:?\:|\/|-|\./;                                                                  # "non memory" cluster: no backreference
85
    my $format = (@_) ? _recognize_format(shift) : ( $self->{'dateformat'} || _prefformat() );
88
    my $format = (@_) ? _recognize_format(shift) : ( $self->{'dateformat'} || _prefformat() );
86
89
87
    # Extra layer of checking $self->{'dateformat'}.
90
    # Extra layer of checking $self->{'dateformat'}.
Lines 213-218 sub format { # get or set dateformat: iso, metric, us, etc. Link Here
213
    $self->{'dateformat'} = _recognize_format(shift);
216
    $self->{'dateformat'} = _recognize_format(shift);
214
}
217
}
215
218
219
# get format string, eg. "yyyy-mm-dd"
220
sub formatstr {
221
    my $self = shift;
222
    return $format_map{$self->{'dateformat'}};
223
}
224
216
sub visual {
225
sub visual {
217
    my $self = shift;
226
    my $self = shift;
218
    if (@_) {
227
    if (@_) {
(-)a/C4/Templates.pm (+1 lines)
Lines 112-117 sub output { Link Here
112
    $vars->{opacsmallimage} = C4::Context->preference('opacsmallimage');
112
    $vars->{opacsmallimage} = C4::Context->preference('opacsmallimage');
113
    $vars->{opaclayoutstylesheet} =
113
    $vars->{opaclayoutstylesheet} =
114
        C4::Context->preference('opaclayoutstylesheet');
114
        C4::Context->preference('opaclayoutstylesheet');
115
    $vars->{dateformatstyle} = C4::Dates->new()->formatstr();
115
116
116
    # add variables set via param to $vars for processing
117
    # add variables set via param to $vars for processing
117
    # and clean any utf8 mess
118
    # and clean any utf8 mess
(-)a/Koha/DateUtils.pm (+9 lines)
Lines 68-73 sub dt_from_string { Link Here
68
            $date_string =~ s#-#/#g;
68
            $date_string =~ s#-#/#g;
69
            $date_string =~ s/^00/01/;    # system allows the 0th of the month
69
            $date_string =~ s/^00/01/;    # system allows the 0th of the month
70
            $date_string =~ s#^(\d{1,2})/(\d{1,2})#$2/$1#;
70
            $date_string =~ s#^(\d{1,2})/(\d{1,2})#$2/$1#;
71
        } elsif ( $date_format eq 'dmydot' ) {
72
            $date_string =~ s#\.#/#g;
73
            $date_string =~ s/^00/01/;    # system allows the 0th of the month
74
            $date_string =~ s#^(\d{1,2})/(\d{1,2})#$2/$1#;
71
        } else {
75
        } else {
72
            if ( $date_format eq 'iso' ) {
76
            if ( $date_format eq 'iso' ) {
73
                $date_string =~ s/-00/-01/;
77
                $date_string =~ s/-00/-01/;
Lines 140-145 sub output_pref { Link Here
140
          ? $dt->strftime("%d/%m/%Y")
144
          ? $dt->strftime("%d/%m/%Y")
141
          : $dt->strftime("%d/%m/%Y $time");
145
          : $dt->strftime("%d/%m/%Y $time");
142
    }
146
    }
147
    elsif ( $pref =~ m/^dmydot/ ) {
148
        return $dateonly
149
          ? $dt->strftime("%d.%m.%Y")
150
          : $dt->strftime("%d.%m.%Y $time");
151
    }
143
    elsif ( $pref =~ m/^us/ ) {
152
    elsif ( $pref =~ m/^us/ ) {
144
153
145
        return $dateonly
154
        return $dateonly
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 83-89 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
83
('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page.  NOTE: this can slow down search response time significantly','YesNo'),
83
('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page.  NOTE: this can slow down search response time significantly','YesNo'),
84
('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'),
84
('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'),
85
('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'),
85
('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'),
86
('dateformat','us','metric|us|iso','Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd)','Choice'),
86
('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'),
87
('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'),
87
('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'),
88
('decreaseLoanHighHolds',NULL,'','Decreases the loan period for items with number of holds above the threshold specified in decreaseLoanHighHoldsValue','YesNo'),
88
('decreaseLoanHighHolds',NULL,'','Decreases the loan period for items with number of holds above the threshold specified in decreaseLoanHighHoldsValue','YesNo'),
89
('decreaseLoanHighHoldsDuration',NULL,'','Specifies a number of days that a loan is reduced to when used in conjunction with decreaseLoanHighHolds','Integer'),
89
('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 (+10 lines)
Lines 8106-8111 if(CheckVersion($DBversion)) { Link Here
8106
    SetVersion($DBversion);
8106
    SetVersion($DBversion);
8107
}
8107
}
8108
8108
8109
$DBversion = "3.15.00.XXX";
8110
if(CheckVersion($DBversion)) {
8111
    $dbh->do(q{
8112
        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'
8113
    });
8114
    print "Upgrade to $DBversion done (Bug 12072 - New dateformat dd.mm.yyyy)\n";
8115
    SetVersion($DBversion);
8116
}
8117
8118
8109
=head1 FUNCTIONS
8119
=head1 FUNCTIONS
8110
8120
8111
=head2 TableExists($table)
8121
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc (-14 / +2 lines)
Lines 3-24 Link Here
3
3
4
var debug    = "[% debug %]";
4
var debug    = "[% debug %]";
5
var dformat  = "[% dateformat %]";
5
var dformat  = "[% dateformat %]";
6
var sentmsg = 0;
7
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
6
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
8
7
9
function Date_from_syspref(dstring) {
8
function Date_from_syspref(dstring) {
10
        var dateX = dstring.split(/[-/]/);
9
    return $.datepicker.parseDate( "[% dateformatstyle | replace('yyyy', 'yy') %]", dstring );
11
        if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));}
12
        if (dformat === "iso") {
13
                return new Date(dateX[0], (dateX[1] - 1), dateX[2]);  // YYYY-MM-DD to (YYYY,m(0-11),d)
14
        } else if (dformat === "us") {
15
                return new Date(dateX[2], (dateX[0] - 1), dateX[1]);  // MM/DD/YYYY to (YYYY,m(0-11),d)
16
        } else if (dformat === "metric") {
17
                return new Date(dateX[2], (dateX[1] - 1), dateX[0]);  // DD/MM/YYYY to (YYYY,m(0-11),d)
18
        } else {
19
                if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);}
20
                return 0;
21
        }
22
}
10
}
23
11
24
/* Instead of including multiple localization files as you would normally see with
12
/* Instead of including multiple localization files as you would normally see with
Lines 37-43 jQuery(function($){ Link Here
37
        dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")],
25
        dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")],
38
        dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
26
        dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
39
        weekHeader: _("Wk"),
27
        weekHeader: _("Wk"),
40
        dateFormat: "[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]",
28
        dateFormat: "[% dateformatstyle | replace("yyyy", "yy") %]",
41
        firstDay: [% CalendarFirstDayOfWeek %],
29
        firstDay: [% CalendarFirstDayOfWeek %],
42
        isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
30
        isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
43
        showMonthAfterYear: false,
31
        showMonthAfterYear: false,
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/date-format.inc (-1 / +1 lines)
Line 1 Link Here
1
[% IF ( dateformat == "us" ) %](MM/DD/YYYY)[% ELSIF ( dateformat == "metric" ) %](DD/MM/YYYY)[% ELSE %](YYYY-MM-DD)[% END %]
1
([% dateformatstyle | upper %])
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-8 / +1 lines)
Lines 24-39 Link Here
24
                <option value='sort2'>Sort field 2</option>
24
                <option value='sort2'>Sort field 2</option>
25
            </select>
25
            </select>
26
            <script type="text/javascript">
26
            <script type="text/javascript">
27
                [% SET dateformat = Koha.Preference('dateformat') %]
28
                $("#searchfields").change(function() {
27
                $("#searchfields").change(function() {
29
                    if ( $(this).val() == 'dateofbirth' ) {
28
                    if ( $(this).val() == 'dateofbirth' ) {
30
                        [% IF dateformat == 'us' %]
29
                            var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format '[% dateformatstyle | upper %]'");
31
                            var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'MM/DD/YYYY'");
32
                        [% ELSIF dateformat == 'iso' %]
33
                            var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'YYYY-MM-DD'");
34
                        [% ELSIF dateformat == 'metric' %]
35
                            var MSG_DATE_FORMAT = _("Dates of birth should be entered in the format 'DD/MM/YYYY'");
36
                        [% END %]
37
                        $('#searchmember').attr("title",MSG_DATE_FORMAT).tooltip('show');
30
                        $('#searchmember').attr("title",MSG_DATE_FORMAT).tooltip('show');
38
                    } else {
31
                    } else {
39
                        $('#searchmember').tooltip('destroy');
32
                        $('#searchmember').tooltip('destroy');
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref (+1 lines)
Lines 6-11 I18N/L10N: Link Here
6
          choices:
6
          choices:
7
              us: mm/dd/yyyy
7
              us: mm/dd/yyyy
8
              metric: dd/mm/yyyy
8
              metric: dd/mm/yyyy
9
              dmydot: dd.mm.yyyy
9
              iso: yyyy-mm-dd
10
              iso: yyyy-mm-dd
10
        - .
11
        - .
11
    -
12
    -
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt (-1 / +1 lines)
Lines 37-43 var NO_UPLOAD_PENDING_MESSAGE = _("You do not have any pending transactions in t Link Here
37
37
38
var start;
38
var start;
39
39
40
var dateformat = '[% IF ( dateformat_us ) %]mm/dd/yy[% ELSIF ( dateformat_metric ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]';
40
var dateformat = '[% dateformatstyle | replace("yyyy", "yy") %]';
41
41
42
function checkin(barcode, item, error) {
42
function checkin(barcode, item, error) {
43
    var alerts = checkAlerts(barcode, item);
43
    var alerts = checkAlerts(barcode, item);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/holidays.tt (-6 / +2 lines)
Lines 255-263 td.repeatableyearly a.ui-state-default { background: #FFFF99 none; color : Bl Link Here
255
            <li>
255
            <li>
256
                <strong>From Date:</strong>
256
                <strong>From Date:</strong>
257
                <span id="showDaynameOutput"></span>, 
257
                <span id="showDaynameOutput"></span>, 
258
                
258
                [% dateformatstyle | replace('yyyy', '<span id="showYearOutput"></span>') | replace('mm', '<span id="showMonthOutput"></span>') | replace('dd', '<span id="showDayOutput"></span>') %]
259
                                [% IF ( dateformat == "us" ) %]<span id="showMonthOutput"></span>/<span id="showDayOutput"></span>/<span id="showYearOutput"></span>[% ELSIF ( dateformat == "metric" ) %]<span id="showDayOutput"></span>/<span id="showMonthOutput"></span>/<span id="showYearOutput"></span>[% ELSE %]<span id="showYearOutput"></span>/<span id="showMonthOutput"></span>/<span id="showDayOutput"></span>[% END %]
260
261
                <input type="hidden" id="showDayname" name="showDayname" />
259
                <input type="hidden" id="showDayname" name="showDayname" />
262
                <input type="hidden" id="showWeekday" name="showWeekday" />
260
                <input type="hidden" id="showWeekday" name="showWeekday" />
263
                <input type="hidden" id="showDay" name="showDay" />
261
                <input type="hidden" id="showDay" name="showDay" />
Lines 326-334 td.repeatableyearly a.ui-state-default { background: #FFFF99 none; color : Bl Link Here
326
            <li>
324
            <li>
327
                <strong>From date:</strong>
325
                <strong>From date:</strong>
328
                <span id="newDaynameOutput"></span>, 
326
                <span id="newDaynameOutput"></span>, 
329
327
                [% dateformatstyle | replace('yyyy', '<span id="newYearOutput"></span>') | replace('mm', '<span id="newMonthOutput"></span>') | replace('dd', '<span id="newDayOutput"></span>') %]
330
                         [% IF ( dateformat == "us" ) %]<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>/<span id="newYearOutput"></span>[% ELSIF ( dateformat == "metric" ) %]<span id="newDayOutput"></span>/<span id="newMonthOutput"></span>/<span id="newYearOutput"></span>[% ELSE %]<span id="newYearOutput"></span>/<span id="newMonthOutput"></span>/<span id="newDayOutput"></span>[% END %]
331
332
                <input type="hidden" id="newDayname" name="showDayname" />
328
                <input type="hidden" id="newDayname" name="showDayname" />
333
                <input type="hidden" id="newWeekday" name="newWeekday" />
329
                <input type="hidden" id="newWeekday" name="newWeekday" />
334
                <input type="hidden" id="newDay" name="newDay" />
330
                <input type="hidden" id="newDay" name="newDay" />
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc (-14 / +2 lines)
Lines 2-23 Link Here
2
    //<![CDATA[
2
    //<![CDATA[
3
        var debug    = "[% debug %]";
3
        var debug    = "[% debug %]";
4
        var dformat  = "[% dateformat %]";
4
        var dformat  = "[% dateformat %]";
5
        var sentmsg = 0;
6
        if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
5
        if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
7
6
8
        function Date_from_syspref(dstring) {
7
        function Date_from_syspref(dstring) {
9
                var dateX = dstring.split(/[-/]/);
8
           return $.datepicker.parseDate( "[% dateformatstyle | replace('yyyy', 'yy') %]", dstring );
10
                if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));}
11
                if (dformat === "iso") {
12
                        return new Date(dateX[0], (dateX[1] - 1), dateX[2]);  // YYYY-MM-DD to (YYYY,m(0-11),d)
13
                } else if (dformat === "us") {
14
                        return new Date(dateX[2], (dateX[0] - 1), dateX[1]);  // MM/DD/YYYY to (YYYY,m(0-11),d)
15
                } else if (dformat === "metric") {
16
                        return new Date(dateX[2], (dateX[1] - 1), dateX[0]);  // DD/MM/YYYY to (YYYY,m(0-11),d)
17
                } else {
18
                        if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);}
19
                        return 0;
20
                }
21
        }
9
        }
22
10
23
        /* Instead of including multiple localization files as you would normally see with
11
        /* Instead of including multiple localization files as you would normally see with
Lines 36-42 Link Here
36
                dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")],
24
                dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")],
37
                dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
25
                dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
38
                weekHeader: _("Wk"),
26
                weekHeader: _("Wk"),
39
                dateFormat: '[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]',
27
                dateFormat: '[% dateformatstyle | replace("yyyy", "yy") %]',
40
                firstDay: [% CalendarFirstDayOfWeek %],
28
                firstDay: [% CalendarFirstDayOfWeek %],
41
                isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
29
                isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
42
                showMonthAfterYear: false,
30
                showMonthAfterYear: false,
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/date-format.inc (-1 / +1 lines)
Line 1 Link Here
1
<span class="dateformat">[% IF ( dateformat == "us" ) %](MM/DD/YYYY)[% ELSIF ( dateformat == "metric" ) %](DD/MM/YYYY)[% ELSE %](YYYY-MM-DD)[% END %]</span>
1
<span class="dateformat">([% dateformatstyle | upper %])</span>
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/calendar.inc (-14 / +2 lines)
Lines 3-24 Link Here
3
3
4
var debug    = "[% debug %]";
4
var debug    = "[% debug %]";
5
var dformat  = "[% dateformat %]";
5
var dformat  = "[% dateformat %]";
6
var sentmsg = 0;
7
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
6
if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");}
8
7
9
function Date_from_syspref(dstring) {
8
function Date_from_syspref(dstring) {
10
        var dateX = dstring.split(/[-/]/);
9
    return $.datepicker.parseDate( "[% dateformatstyle | replace('yyyy', 'yy') %]", dstring );
11
        if (debug > 1 && sentmsg < 1) {sentmsg++; alert("Date_from_syspref(" + dstring + ") splits to:\n" + dateX.join("\n"));}
12
        if (dformat === "iso") {
13
                return new Date(dateX[0], (dateX[1] - 1), dateX[2]);  // YYYY-MM-DD to (YYYY,m(0-11),d)
14
        } else if (dformat === "us") {
15
                return new Date(dateX[2], (dateX[0] - 1), dateX[1]);  // MM/DD/YYYY to (YYYY,m(0-11),d)
16
        } else if (dformat === "metric") {
17
                return new Date(dateX[2], (dateX[1] - 1), dateX[0]);  // DD/MM/YYYY to (YYYY,m(0-11),d)
18
        } else {
19
                if (debug > 0) {alert("KOHA ERROR - Unrecognized date format: " +dformat);}
20
                return 0;
21
        }
22
}
10
}
23
11
24
/* Instead of including multiple localization files as you would normally see with
12
/* Instead of including multiple localization files as you would normally see with
Lines 37-43 jQuery(function($){ Link Here
37
        dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")],
25
        dayNamesShort: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")],
38
        dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
26
        dayNamesMin: [_("Su"),_("Mo"),_("Tu"),_("We"),_("Th"),_("Fr"),_("Sa")],
39
        weekHeader: _("Wk"),
27
        weekHeader: _("Wk"),
40
        dateFormat: '[% IF ( dateformat == "us" ) %]mm/dd/yy[% ELSIF ( dateformat == "metric" ) %]dd/mm/yy[% ELSE %]yy-mm-dd[% END %]',
28
        dateFormat: '[% dateformatstyle | replace("yyyy", "yy") %]',
41
        firstDay: [% CalendarFirstDayOfWeek %],
29
        firstDay: [% CalendarFirstDayOfWeek %],
42
        isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
30
        isRTL: [% IF ( bidi ) %]true[% ELSE %]false[% END %],
43
        showMonthAfterYear: false,
31
        showMonthAfterYear: false,
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/date-format.inc (-1 / +1 lines)
Line 1 Link Here
1
[% IF ( dateformat == "us" ) %](MM/DD/YYYY)[% ELSIF ( dateformat == "metric" ) %](DD/MM/YYYY)[% ELSE %](YYYY-MM-DD)[% END %]
1
([% dateformatstyle | upper %])
(-)a/tools/exceptionHolidays.pl (-14 / +5 lines)
Lines 40-60 if ($description) { Link Here
40
    $description = '';
40
    $description = '';
41
}   
41
}   
42
42
43
# We format the date
43
44
my $datecancelrange = C4::Dates->new($datecancelrange)->output('iso');
44
my @dateend = split(/[\/-]/, $datecancelrange);
45
my @dateend = split(/[\/-]/, $datecancelrange);
45
if (C4::Context->preference("dateformat") eq "metric") {
46
$year1 = $dateend[0];
46
    $day1 = $dateend[0];
47
$month1 = $dateend[1];
47
    $month1 = $dateend[1];
48
$day1 = $dateend[2];
48
    $year1 = $dateend[2];
49
}elsif (C4::Context->preference("dateformat") eq "us") {
50
    $month1 = $dateend[0];
51
    $day1 = $dateend[1];
52
    $year1 = $dateend[2];
53
} else {
54
    $year1 = $dateend[0];
55
    $month1 = $dateend[1];
56
    $day1 = $dateend[2];
57
}
58
49
59
# We make an array with holiday's days
50
# We make an array with holiday's days
60
my @holiday_list;
51
my @holiday_list;
(-)a/tools/newHolidays.pl (-14 / +5 lines)
Lines 34-53 my $calendardate = sprintf("%04d-%02d-%02d", $year, $month, $day); Link Here
34
my $isodate             = C4::Dates->new($calendardate, 'iso');
34
my $isodate             = C4::Dates->new($calendardate, 'iso');
35
$calendardate           = $isodate->output('syspref');
35
$calendardate           = $isodate->output('syspref');
36
36
37
my $dateofrange = C4::Dates->new($dateofrange)->output('iso');
37
my @dateend = split(/[\/-]/, $dateofrange);
38
my @dateend = split(/[\/-]/, $dateofrange);
38
if (C4::Context->preference("dateformat") eq "metric") {
39
$year1 = $dateend[0];
39
    $day1 = $dateend[0];
40
$month1 = $dateend[1];
40
    $month1 = $dateend[1];
41
$day1 = $dateend[2];
41
    $year1 = $dateend[2];
42
42
}elsif (C4::Context->preference("dateformat") eq "us") {
43
    $month1 = $dateend[0];
44
    $day1 = $dateend[1];
45
    $year1 = $dateend[2];
46
} else {
47
    $year1 = $dateend[0];
48
    $month1 = $dateend[1];
49
    $day1 = $dateend[2];
50
}
51
$title || ($title = '');
43
$title || ($title = '');
52
if ($description) {
44
if ($description) {
53
	$description =~ s/\r/\\r/g;
45
	$description =~ s/\r/\\r/g;
54
- 

Return to bug 12072