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

(-)a/Koha/DateUtils.pm (-9 / +21 lines)
Lines 66-71 sub dt_from_string { Link Here
66
    }
66
    }
67
67
68
    my $regex;
68
    my $regex;
69
70
    # The fallback format is sql/iso
71
    my $fallback_re = qr|
72
        (?<year>\d{4})
73
        -
74
        (?<month>\d{2})
75
        -
76
        (?<day>\d{2})
77
    |xms;
78
69
    if ( $date_format eq 'metric' ) {
79
    if ( $date_format eq 'metric' ) {
70
        # metric format is "dd/mm/yyyy[ hh:mm:ss]"
80
        # metric format is "dd/mm/yyyy[ hh:mm:ss]"
71
        $regex = qr|
81
        $regex = qr|
Lines 87-100 sub dt_from_string { Link Here
87
        |xms;
97
        |xms;
88
    }
98
    }
89
    elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) {
99
    elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) {
90
        # iso format is yyyy-dd-mm[ hh:mm:ss]"
100
        # iso or sql format are yyyy-dd-mm[ hh:mm:ss]"
91
        $regex = qr|
101
        $regex = $fallback_re;
92
            (?<year>\d{4})
93
            -
94
            (?<month>\d{2})
95
            -
96
            (?<day>\d{2})
97
        |xms;
98
    }
102
    }
99
    else {
103
    else {
100
        die "Invalid dateformat parameter ($date_format)";
104
        die "Invalid dateformat parameter ($date_format)";
Lines 124-129 sub dt_from_string { Link Here
124
            minute => $+{minute},
128
            minute => $+{minute},
125
            second => $+{second},
129
            second => $+{second},
126
        );
130
        );
131
    } elsif ( $date_string =~ $fallback_re ) {
132
        %dt_params = (
133
            year   => $+{year},
134
            month  => $+{month},
135
            day    => $+{day},
136
            hour   => $+{hour},
137
            minute => $+{minute},
138
            second => $+{second},
139
        );
127
    }
140
    }
128
    else {
141
    else {
129
        die "The given date ($date_string) does not match the date format ($date_format)";
142
        die "The given date ($date_string) does not match the date format ($date_format)";
130
- 

Return to bug 13601