1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
use Test;
use strict;
BEGIN { plan tests => 18; };
use Class::Date qw(:errors gmdate);
$Class::Date::DST_ADJUST=1;
ok(1);
$a = gmdate("195xwerf9");
ok !$a;
ok $a->error, E_UNPARSABLE;
ok $a->errstr, "Unparsable date or time: 195xwerf9\n";
$Class::Date::RANGE_CHECK=0;
$a = gmdate("2001-02-31");
ok $a, "2001-03-03";
$Class::Date::RANGE_CHECK=1;
$a = gmdate("2001-02-31");
ok !$a;
ok $a ? 0 : 1;
ok $a->error, E_RANGE;
ok $a->errstr, "Range check on date or time failed\n";
$a = gmdate("2006-2-6")->clone( month => -1);
ok !$a;
ok $a ? 0 : 1;
$a = new Class::Date(undef);
ok ! $a;
ok $a ? 0 : 1;
ok $a->error, E_UNDEFINED;
ok $a->errstr, "Undefined date object\n";
$a = gmdate("2006-2-6")->clone(month => 16);
ok !$a;
ok $a ? 0 : 1;
$a = gmdate("2001-05-04 07:09:09") + [1,-2,-4];
ok $a;
|