| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use warnings; |
| 4 | use strict; |
| 5 | use Test::Inter; |
| 6 | $::ti = new Test::Inter $0; |
| 7 | require "tests.pl"; |
| 8 | |
| 9 | our $obj = new Date::Manip::Date; |
| 10 | $obj->config("forcedate","2000-01-21-00:00:00,America/New_York"); |
| 11 | |
| 12 | sub test { |
| 13 | my(@test)=@_; |
| 14 | if ($test[0] eq "config") { |
| 15 | shift(@test); |
| 16 | $obj->config(@test); |
| 17 | return (); |
| 18 | } |
| 19 | |
| 20 | $obj->_init(); |
| 21 | my $err = $obj->parse_date(@test); |
| 22 | if ($err) { |
| 23 | return $obj->err(); |
| 24 | } else { |
| 25 | my $d1 = $obj->value(); |
| 26 | my $d2 = $obj->value("gmt"); |
| 27 | return($d1,$d2); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | my $tests=" |
| 32 | |
| 33 | # ISO 8601 (YYMMDD) |
| 34 | |
| 35 | 19930601 => 1993060100:00:00 1993060104:00:00 |
| 36 | |
| 37 | 1993-06-01 => 1993060100:00:00 1993060104:00:00 |
| 38 | |
| 39 | -930601 => 1993060100:00:00 1993060104:00:00 |
| 40 | |
| 41 | -93-06-01 => 1993060100:00:00 1993060104:00:00 |
| 42 | |
| 43 | 930601 => 1993060100:00:00 1993060104:00:00 |
| 44 | |
| 45 | 93-06-01 => 1993060100:00:00 1993060104:00:00 |
| 46 | |
| 47 | --0601 => 2000060100:00:00 2000060104:00:00 |
| 48 | |
| 49 | --06-01 => 2000060100:00:00 2000060104:00:00 |
| 50 | |
| 51 | ---07 => 2000010700:00:00 2000010705:00:00 |
| 52 | |
| 53 | 1996-11 => 1996110100:00:00 1996110105:00:00 |
| 54 | |
| 55 | 1996 => 1996010100:00:00 1996010105:00:00 |
| 56 | |
| 57 | -9611 => 1996110100:00:00 1996110105:00:00 |
| 58 | |
| 59 | -96-11 => 1996110100:00:00 1996110105:00:00 |
| 60 | |
| 61 | -96 => 1996010100:00:00 1996010105:00:00 |
| 62 | |
| 63 | --11 => 2000110100:00:00 2000110105:00:00 |
| 64 | |
| 65 | 1993-063 => 1993030400:00:00 1993030405:00:00 |
| 66 | |
| 67 | 1993063 => 1993030400:00:00 1993030405:00:00 |
| 68 | |
| 69 | 93-063 => 1993030400:00:00 1993030405:00:00 |
| 70 | |
| 71 | 93063 => 1993030400:00:00 1993030405:00:00 |
| 72 | |
| 73 | -93-063 => 1993030400:00:00 1993030405:00:00 |
| 74 | |
| 75 | -93063 => 1993030400:00:00 1993030405:00:00 |
| 76 | |
| 77 | -063 => 2000030300:00:00 2000030305:00:00 |
| 78 | |
| 79 | # ISO 8601 (YYWwwD) |
| 80 | |
| 81 | 1993W101 => 1993030800:00:00 1993030805:00:00 |
| 82 | |
| 83 | 1993W107 => 1993031400:00:00 1993031405:00:00 |
| 84 | |
| 85 | 1993-W10-1 => 1993030800:00:00 1993030805:00:00 |
| 86 | |
| 87 | 1993-W10-7 => 1993031400:00:00 1993031405:00:00 |
| 88 | |
| 89 | 93W101 => 1993030800:00:00 1993030805:00:00 |
| 90 | |
| 91 | 93W107 => 1993031400:00:00 1993031405:00:00 |
| 92 | |
| 93 | 93-W10-1 => 1993030800:00:00 1993030805:00:00 |
| 94 | |
| 95 | 93-W10-7 => 1993031400:00:00 1993031405:00:00 |
| 96 | |
| 97 | -93W101 => 1993030800:00:00 1993030805:00:00 |
| 98 | |
| 99 | -93W107 => 1993031400:00:00 1993031405:00:00 |
| 100 | |
| 101 | -93-W10-1 => 1993030800:00:00 1993030805:00:00 |
| 102 | |
| 103 | -93-W10-7 => 1993031400:00:00 1993031405:00:00 |
| 104 | |
| 105 | -W101 => 2000030600:00:00 2000030605:00:00 |
| 106 | |
| 107 | -W107 => 2000031200:00:00 2000031205:00:00 |
| 108 | |
| 109 | -W10-1 => 2000030600:00:00 2000030605:00:00 |
| 110 | |
| 111 | -W10-7 => 2000031200:00:00 2000031205:00:00 |
| 112 | |
| 113 | -W-1 => 2000011700:00:00 2000011705:00:00 |
| 114 | |
| 115 | -W-7 => 2000012300:00:00 2000012305:00:00 |
| 116 | |
| 117 | ---1 => 2000011700:00:00 2000011705:00:00 |
| 118 | |
| 119 | ---7 => 2000012300:00:00 2000012305:00:00 |
| 120 | |
| 121 | config firstday 7 => |
| 122 | |
| 123 | 1993W101 => 1993030700:00:00 1993030705:00:00 |
| 124 | |
| 125 | 1993W107 => 1993031300:00:00 1993031305:00:00 |
| 126 | |
| 127 | config firstday 1 => |
| 128 | |
| 129 | 1993W10 => 1993030800:00:00 1993030805:00:00 |
| 130 | |
| 131 | 1993-W10 => 1993030800:00:00 1993030805:00:00 |
| 132 | |
| 133 | 93W10 => 1993030800:00:00 1993030805:00:00 |
| 134 | |
| 135 | 93-W10 => 1993030800:00:00 1993030805:00:00 |
| 136 | |
| 137 | -93W10 => 1993030800:00:00 1993030805:00:00 |
| 138 | |
| 139 | -93-W10 => 1993030800:00:00 1993030805:00:00 |
| 140 | |
| 141 | -W10 => 2000030600:00:00 2000030605:00:00 |
| 142 | |
| 143 | W10 => 2000030600:00:00 2000030605:00:00 |
| 144 | |
| 145 | "; |
| 146 | |
| 147 | $::ti->tests(func => \&test, |
| 148 | tests => $tests); |
| 149 | $::ti->done_testing(); |
| 150 | |
| 151 | #Local Variables: |
| 152 | #mode: cperl |
| 153 | #indent-tabs-mode: nil |
| 154 | #cperl-indent-level: 3 |
| 155 | #cperl-continued-statement-offset: 2 |
| 156 | #cperl-continued-brace-offset: 0 |
| 157 | #cperl-brace-offset: 0 |
| 158 | #cperl-brace-imaginary-offset: 0 |
| 159 | #cperl-label-offset: 0 |
| 160 | #End: |