Date-Easy
view release on metacpan or search on metacpan
throws_ok { $multiple - $d } qr/can't subtract from a unit/, "date subtraction fails backwards: $_";
}
else
{
throws_ok { $d + $multiple } qr/cannot call/, "date addition of $_ fails";
throws_ok { $d - $multiple } qr/cannot call/, "date subtraction of $_ fails";
}
}
# test prototypes and also try a few more complex formulae
my $dt = datetime("Jan-02-2003 04:05:06");
my $dt2;
lives_ok { $dt2 = $dt + 2*days + 5*hours - 8*years + 10*seconds - 3*minutes } "complex example parses correctly";
is $dt2->strftime($FMT), "1995/01/04 09:02:16", "complex example (including prototypes) works";
# test a few more errors
throws_ok { seconds + minutes } qr/can't locate object method/i, "cannot add two units together";
throws_ok { seconds - minutes } qr/can't subtract from a unit/i, "cannot subtract two units from each other";
( run in 0.249 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )