| 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-12: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 |
my $err = $obj->parse(@test); |
| 21 |
if ($err) { |
| 22 |
return $obj->err(); |
| 23 |
} else { |
| 24 |
my $d1 = $obj->value(); |
| 25 |
my $d2 = $obj->value("gmt"); |
| 26 |
return($d1,$d2); |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
my $tests=" |
| 31 |
|
| 32 |
Friday => 2000012100:00:00 2000012105:00:00 |
| 33 |
|
| 34 |
'Friday at 13:00' => 2000012113:00:00 2000012118:00:00 |
| 35 |
|
| 36 |
Monday => 2000011700:00:00 2000011705:00:00 |
| 37 |
|
| 38 |
'Monday at 13:00' => 2000011713:00:00 2000011718:00:00 |
| 39 |
|
| 40 |
Saturday => 2000012200:00:00 2000012205:00:00 |
| 41 |
|
| 42 |
'Saturday at 13:00' => 2000012213:00:00 2000012218:00:00 |
| 43 |
|
| 44 |
### |
| 45 |
|
| 46 |
'next friday' => 2000012800:00:00 2000012805:00:00 |
| 47 |
|
| 48 |
'next sunday' => 2000012300:00:00 2000012305:00:00 |
| 49 |
|
| 50 |
'last friday' => 2000011400:00:00 2000011405:00:00 |
| 51 |
|
| 52 |
'last sunday' => 2000011600:00:00 2000011605:00:00 |
| 53 |
|
| 54 |
'last sunday at 13:00' => 2000011613:00:00 2000011618:00:00 |
| 55 |
|
| 56 |
#### |
| 57 |
|
| 58 |
'next year' => 2001012100:00:00 2001012105:00:00 |
| 59 |
|
| 60 |
'last year' => 1999012100:00:00 1999012105:00:00 |
| 61 |
|
| 62 |
'next month' => 2000022100:00:00 2000022105:00:00 |
| 63 |
|
| 64 |
'last month' => 1999122100:00:00 1999122105:00:00 |
| 65 |
|
| 66 |
'next week' => 2000012800:00:00 2000012805:00:00 |
| 67 |
|
| 68 |
'last week' => 2000011400:00:00 2000011405:00:00 |
| 69 |
|
| 70 |
'last week at 13:00' => 2000011413:00:00 2000011418:00:00 |
| 71 |
|
| 72 |
### |
| 73 |
|
| 74 |
'last day in October 1997' => 1997103100:00:00 1997103105:00:00 |
| 75 |
|
| 76 |
'last day in October' => 2000103100:00:00 2000103105:00:00 |
| 77 |
|
| 78 |
### |
| 79 |
|
| 80 |
'last tue in Jun 96' => 1996062500:00:00 1996062504:00:00 |
| 81 |
|
| 82 |
'last tueSday of Jan' => 2000012500:00:00 2000012505:00:00 |
| 83 |
|
| 84 |
### |
| 85 |
|
| 86 |
'last Tue in 1997' => 1997123000:00:00 1997123005:00:00 |
| 87 |
|
| 88 |
### |
| 89 |
|
| 90 |
'first tue in Jun 1996' => 1996060400:00:00 1996060404:00:00 |
| 91 |
|
| 92 |
'3rd tuesday in Jun 96' => 1996061800:00:00 1996061804:00:00 |
| 93 |
|
| 94 |
'3rd tuesday in Jun 96 at 10:30am' => 1996061810:30:00 1996061814:30:00 |
| 95 |
|
| 96 |
'3rd tuesday in Jun 96 at 10:30 pm' => 1996061822:30:00 1996061902:30:00 |
| 97 |
|
| 98 |
'3rd tuesday in Jun 96 at 10:30 pm GMT' => 1996061822:30:00 1996061822:30:00 |
| 99 |
|
| 100 |
'3rd tuesday in Jun 96 at 10:30 pm CDT' => 1996061822:30:00 1996061903:30:00 |
| 101 |
|
| 102 |
'first tue in Jun' => 2000060600:00:00 2000060604:00:00 |
| 103 |
|
| 104 |
'3rd tuesday in Jun' => 2000062000:00:00 2000062004:00:00 |
| 105 |
|
| 106 |
### |
| 107 |
|
| 108 |
'Dec 1st 1970' => 1970120100:00:00 1970120105:00:00 |
| 109 |
|
| 110 |
'Dec 1st' => 2000120100:00:00 2000120105:00:00 |
| 111 |
|
| 112 |
'1st Dec 1970' => 1970120100:00:00 1970120105:00:00 |
| 113 |
|
| 114 |
'1st Dec' => 2000120100:00:00 2000120105:00:00 |
| 115 |
|
| 116 |
'1970 Dec 1st' => 1970120100:00:00 1970120105:00:00 |
| 117 |
|
| 118 |
'1970 1st Dec' => 1970120100:00:00 1970120105:00:00 |
| 119 |
|
| 120 |
### |
| 121 |
|
| 122 |
'22nd sunday' => 2000052800:00:00 2000052804:00:00 |
| 123 |
|
| 124 |
'twenty-second sunday 1996' => 1996060200:00:00 1996060204:00:00 |
| 125 |
|
| 126 |
'22nd sunday in 1996' => 1996060200:00:00 1996060204:00:00 |
| 127 |
|
| 128 |
### |
| 129 |
|
| 130 |
'Friday week' => 2000012800:00:00 2000012805:00:00 |
| 131 |
|
| 132 |
'Monday week' => 2000012400:00:00 2000012405:00:00 |
| 133 |
|
| 134 |
### |
| 135 |
|
| 136 |
today => 2000012100:00:00 2000012105:00:00 |
| 137 |
|
| 138 |
'today at 14:30' => 2000012114:30:00 2000012119:30:00 |
| 139 |
|
| 140 |
tomorrow => 2000012200:00:00 2000012205:00:00 |
| 141 |
|
| 142 |
'tomorrow at 14:30' => 2000012214:30:00 2000012219:30:00 |
| 143 |
|
| 144 |
yesterday => 2000012000:00:00 2000012005:00:00 |
| 145 |
|
| 146 |
'yesterday at 14:30' => 2000012014:30:00 2000012019:30:00 |
| 147 |
|
| 148 |
'today week' => 2000012800:00:00 2000012805:00:00 |
| 149 |
|
| 150 |
'today week at 14:30' => 2000012814:30:00 2000012819:30:00 |
| 151 |
|
| 152 |
'tomorrow week' => 2000012900:00:00 2000012905:00:00 |
| 153 |
|
| 154 |
'tomorrow week at 14:30' => 2000012914:30:00 2000012919:30:00 |
| 155 |
|
| 156 |
'yesterday week' => 2000012700:00:00 2000012705:00:00 |
| 157 |
|
| 158 |
'yesterday week at 14:30' => 2000012714:30:00 2000012719:30:00 |
| 159 |
|
| 160 |
### |
| 161 |
|
| 162 |
'sunday week 1 1999' => 1999011000:00:00 1999011005:00:00 |
| 163 |
|
| 164 |
'sunday 1st week 1999' => 1999011000:00:00 1999011005:00:00 |
| 165 |
|
| 166 |
'sunday week 1' => 2000010900:00:00 2000010905:00:00 |
| 167 |
|
| 168 |
'sunday 1st week' => 2000010900:00:00 2000010905:00:00 |
| 169 |
|
| 170 |
### |
| 171 |
|
| 172 |
1st => 2000010100:00:00 2000010105:00:00 |
| 173 |
|
| 174 |
tenth => 2000011000:00:00 2000011005:00:00 |
| 175 |
|
| 176 |
### |
| 177 |
|
| 178 |
now => 2000012112:00:00 2000012117:00:00 |
| 179 |
|
| 180 |
'epoch 0' => 1969123119:00:00 1970010100:00:00 |
| 181 |
|
| 182 |
'epoch 400000' => 1970010510:06:40 1970010515:06:40 |
| 183 |
|
| 184 |
'today week' => 2000012800:00:00 2000012805:00:00 |
| 185 |
|
| 186 |
'today week at 4:00' => 2000012804:00:00 2000012809:00:00 |
| 187 |
|
| 188 |
### |
| 189 |
|
| 190 |
'5th Sunday in October 2010' => 2010103100:00:00 2010103104:00:00 |
| 191 |
|
| 192 |
'9th Sunday in October 2010' => '[parse] Invalid date string' |
| 193 |
|
| 194 |
'Sunday, 3rd October 2010' => 2010100300:00:00 2010100304:00:00 |
| 195 |
|
| 196 |
'Monday, 3rd October 2010' => '[parse] Day of week invalid' |
| 197 |
|
| 198 |
'3rd tuesday in Jun 96 at 10:30 pm CET' => 1996061822:30:00 1996061821:30:00 |
| 199 |
|
| 200 |
### |
| 201 |
|
| 202 |
'sunday w 22 in 1996' => 1996060200:00:00 1996060204:00:00 |
| 203 |
|
| 204 |
'sunday 22nd w in 1996' => 1996060200:00:00 1996060204:00:00 |
| 205 |
|
| 206 |
"; |
| 207 |
|
| 208 |
$::ti->tests(func => \&test, |
| 209 |
tests => $tests); |
| 210 |
$::ti->done_testing(); |
| 211 |
|
| 212 |
#Local Variables: |
| 213 |
#mode: cperl |
| 214 |
#indent-tabs-mode: nil |
| 215 |
#cperl-indent-level: 3 |
| 216 |
#cperl-continued-statement-offset: 2 |
| 217 |
#cperl-continued-brace-offset: 0 |
| 218 |
#cperl-brace-offset: 0 |
| 219 |
#cperl-brace-imaginary-offset: 0 |
| 220 |
#cperl-label-offset: 0 |
| 221 |
#End: |