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

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

Return to bug 13601