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

(-)a/koha-tmpl/intranet-tmpl/prog/js/calendar.js (-6 / +6 lines)
Lines 1-4 Link Here
1
/* global debug sentmsg __ dateformat_pref dateformat_string bidi calendarFirstDayOfWeek */
1
/* global debug sentmsg __ dateformat_pref flatpickr_dateformat_string bidi calendarFirstDayOfWeek */
2
/* exported DateTime_from_syspref flatpickr_weekdays flatpickr_months */
2
/* exported DateTime_from_syspref flatpickr_weekdays flatpickr_months */
3
var MSG_PLEASE_ENTER_A_VALID_DATE = ( __("Please enter a valid date (should match %s).") );
3
var MSG_PLEASE_ENTER_A_VALID_DATE = ( __("Please enter a valid date (should match %s).") );
4
if (debug > 1) {
4
if (debug > 1) {
Lines 8-26 if (debug > 1) { Link Here
8
function is_valid_date(date) {
8
function is_valid_date(date) {
9
    // An empty string is considered as a valid date for convenient reasons.
9
    // An empty string is considered as a valid date for convenient reasons.
10
    if (date === '') return 1;
10
    if (date === '') return 1;
11
    var dateformat = dateformat_string;
11
    var dateformat = flatpickr_dateformat_string;
12
    if (dateformat == 'us') {
12
    if (dateformat == 'us') {
13
        if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0;
13
        if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0;
14
        dateformat = 'mm/dd/yy';
14
        dateformat = 'm/d/Y';
15
    } else if (dateformat == 'metric') {
15
    } else if (dateformat == 'metric') {
16
        if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0;
16
        if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0;
17
        dateformat = 'dd/mm/yy';
17
        dateformat = 'd/m/Y';
18
    } else if (dateformat == 'iso') {
18
    } else if (dateformat == 'iso') {
19
        if (date.search(/^\d{4}-\d{2}-\d{2}($|\s)/) == -1) return 0;
19
        if (date.search(/^\d{4}-\d{2}-\d{2}($|\s)/) == -1) return 0;
20
        dateformat = 'yy-mm-dd';
20
        dateformat = 'Y-m-d';
21
    } else if (dateformat == 'dmydot') {
21
    } else if (dateformat == 'dmydot') {
22
        if (date.search(/^\d{2}\.\d{2}\.\d{4}($|\s)/) == -1) return 0;
22
        if (date.search(/^\d{2}\.\d{2}\.\d{4}($|\s)/) == -1) return 0;
23
        dateformat = 'dd.mm.yy';
23
        dateformat = 'd.m.Y';
24
    }
24
    }
25
    try {
25
    try {
26
        flatpickr.parseDate(date, dateformat);
26
        flatpickr.parseDate(date, dateformat);
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc (-19 / +13 lines)
Lines 18-40 Link Here
18
    var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]';
18
    var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]';
19
    var flatpickr_timeformat_string = [% IF Koha.Preference('TimeFormat') == '12hr' %]"G:i K"[% ELSE %]"H:i"[% END %];
19
    var flatpickr_timeformat_string = [% IF Koha.Preference('TimeFormat') == '12hr' %]"G:i K"[% ELSE %]"H:i"[% END %];
20
    var flatpickr_timeformat = [% IF Koha.Preference('TimeFormat') == '12hr' %]false[% ELSE %]true[% END %];
20
    var flatpickr_timeformat = [% IF Koha.Preference('TimeFormat') == '12hr' %]false[% ELSE %]true[% END %];
21
    var dateformat_string = "";
22
    var flatpickr_dateformat_string = "";
21
    var flatpickr_dateformat_string = "";
23
    switch ( dateformat_pref ){
22
    switch ( dateformat_pref ){
24
        case "us":
23
        case "us":
25
            dateformat_string = "mm/dd/yy";
26
            flatpickr_dateformat_string = "m/d/Y";
24
            flatpickr_dateformat_string = "m/d/Y";
27
            break;
25
            break;
28
        case "metric":
26
        case "metric":
29
            dateformat_string = "dd/mm/yy";
30
            flatpickr_dateformat_string = "d/m/Y";
27
            flatpickr_dateformat_string = "d/m/Y";
31
            break;
28
            break;
32
        case "dmydot":
29
        case "dmydot":
33
            dateformat_string = "dd.mm.yy";
34
            flatpickr_dateformat_string = "d.m.Y";
30
            flatpickr_dateformat_string = "d.m.Y";
35
            break;
31
            break;
36
        default:
32
        default:
37
            dateformat_string = "yy-mm-dd";
38
            flatpickr_dateformat_string = "Y-m-d";
33
            flatpickr_dateformat_string = "Y-m-d";
39
    }
34
    }
40
</script>
35
</script>
Lines 94-112 Link Here
94
    function is_valid_date(date) {
89
    function is_valid_date(date) {
95
        // An empty string is considered as a valid date for convenient reasons.
90
        // An empty string is considered as a valid date for convenient reasons.
96
        if (date === '') return 1;
91
        if (date === '') return 1;
97
        var dateformat = dateformat_string;
92
        var dateformat = flatpickr_dateformat_string;
98
        if (dateformat == 'us') {
93
        switch ( dateformat_pref ){
99
            if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0;
94
            case "us":
100
            dateformat = 'mm/dd/yy';
95
                flatpickr_dateformat_string = "m/d/Y";
101
        } else if (dateformat == 'metric') {
96
                break;
102
            if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0;
97
            case "metric":
103
            dateformat = 'dd/mm/yy';
98
                flatpickr_dateformat_string = "d/m/Y";
104
        } else if (dateformat == 'iso') {
99
                break;
105
            if (date.search(/^\d{4}-\d{2}-\d{2}($|\s)/) == -1) return 0;
100
            case "dmydot":
106
            dateformat = 'yy-mm-dd';
101
                flatpickr_dateformat_string = "d.m.Y";
107
        } else if (dateformat == 'dmydot') {
102
                break;
108
            if (date.search(/^\d{2}\.\d{2}\.\d{4}($|\s)/) == -1) return 0;
103
            default:
109
            dateformat = 'dd.mm.yy';
104
                flatpickr_dateformat_string = "Y-m-d";
110
        }
105
        }
111
        try {
106
        try {
112
            flatpickr.parseDate(date, dateformat);
107
            flatpickr.parseDate(date, dateformat);
113
- 

Return to bug 30514