There are a lot of places where the date comes from the DB but the
dateformat parameter is not set to 'sql'.
dt_from_string needs to fallback with this format if the pref format
does not match.
Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
}
my $regex;
+
+ # The fallback format is sql/iso
+ my $fallback_re = qr|
+ (?<year>\d{4})
+ -
+ (?<month>\d{2})
+ -
+ (?<day>\d{2})
+ |xms;
+
if ( $date_format eq 'metric' ) {
# metric format is "dd/mm/yyyy[ hh:mm:ss]"
$regex = qr|
|xms;
}
elsif ( $date_format eq 'iso' or $date_format eq 'sql' ) {
- # iso format is yyyy-dd-mm[ hh:mm:ss]"
- $regex = qr|
- (?<year>\d{4})
- -
- (?<month>\d{2})
- -
- (?<day>\d{2})
- |xms;
+ # iso or sql format are yyyy-dd-mm[ hh:mm:ss]"
+ $regex = $fallback_re;
}
else {
die "Invalid dateformat parameter ($date_format)";
minute => $+{minute},
second => $+{second},
);
+ } elsif ( $date_string =~ $fallback_re ) {
+ %dt_params = (
+ year => $+{year},
+ month => $+{month},
+ day => $+{day},
+ hour => $+{hour},
+ minute => $+{minute},
+ second => $+{second},
+ );
}
else {
die "The given date ($date_string) does not match the date format ($date_format)";