in reply to DateTime::Format::Strptime Parsing Seems to have a Problem?
Hello ozboomer,
tangent beat me to it with %I. But you should also check for errors; e.g.:
my $dmy_fmt = DateTime::Format::Strptime->new ( pattern => '%d/%m/%Y %I:%M:%S %p', time_zone => 'Australia/Victoria', on_error => 'croak', # <-- ADD THIS );
With %H instead of %I, this reports:
13:08 >perl 1989_SoPW.pl $dtnow: !2019-03-25T20:10:32! $lodt: !2019-03-18T10:12:53! Parsed an input with 24-hour and AM/PM values that do not match - "3" +versus "pm" at 1989_SoPW.pl line 48. 13:10 >
— somewhat cryptic, but an indication that DateTime::Format::Strptime is expecting 24-hour and not 12-hour time here.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|