when I ran the code like below:
use feature qw(say);
use Time::Piece;
use DateTime;
use DateTime::Format::MySQL;
say 'Time::Piece now: ', my $tp = Time::Piece->new();
say 'DateTime now: ', my $dt = DateTime->now();
say '---';
say 'with ', my $quite_normal = '2020-07-25T11:32:31';
say '---';
say 'strptime with tp: ', $tp->strptime( $quite_normal, '%Y-%m-%dT%H:%M:%S' );
say 'parse_datetime with dt: ', DateTime::Format::MySQL->parse_datetime($quite_normal);
say '---';
say 'with ', my $wrong = '2020-09-31T11:32:31';
say '---';
my $result;
$result = eval { $tp->strptime( $wrong, '%Y-%m-%dT%H:%M:%S' ) } || "dies";
say 'strptime with tp: ', $result;
$result = eval { DateTime::Format::MySQL->parse_datetime($wrong) } || "dies";
say 'parse_datetime with dt: ', $result;
say '---';
say 'with ', my $wronger = '2020-02-31T11:32:31';
say '---';
$result = eval { $tp->strptime( $wronger, '%Y-%m-%dT%H:%M:%S' ) } || "dies";
say 'strptime with tp: ', $result;
$result = eval { DateTime::Format::MySQL->parse_datetime($wronger) } || "dies";
say 'parse_datetime with dt: ', $result;
say '---';
say 'with ', my $wrongest = '2020-02-34T11:32:31';
say '---';
$result = eval { $tp->strptime( $wrongest, '%Y-%m-%dT%H:%M:%S' ) } || "dies";
say 'strptime with tp: ', $result;
$result = eval { DateTime::Format::MySQL->parse_datetime($wrongest) } || "dies";
say 'parse_datetime with dt: ', $result;
It returns like this:
Time::Piece now: Tue Oct 13 14:34:48 2020
DateTime now: 2020-10-13T05:34:48
---
with 2020-07-25T11:32:31
---
strptime with tp: Sat Jul 25 11:32:31 2020
parse_datetime with dt: 2020-07-25T11:32:31
---
with 2020-09-31T11:32:31
---
strptime with tp: Thu Oct 1 11:32:31 2020
parse_datetime with dt: dies
---
with 2020-02-31T11:32:31
---
strptime with tp: Mon Mar 2 11:32:31 2020
parse_datetime with dt: dies
---
with 2020-02-34T11:32:31
---
strptime with tp: dies
parse_datetime with dt: dies
Is this a specification?
when I ran the code like below:
It returns like this:
Is this a specification?