| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use utf8; |
| 4 | use warnings; |
| 5 | use strict; |
| 6 | use Test::Inter; |
| 7 | $::ti = new Test::Inter $0; |
| 8 | require "tests.pl"; |
| 9 | |
| 10 | our $obj = new Date::Manip::Date; |
| 11 | $obj->config("forcedate","2000-01-21-12:30:45,America/New_York"); |
| 12 | $obj->config("language","French","dateformat","nonUS"); |
| 13 | |
| 14 | sub test { |
| 15 | my(@test)=@_; |
| 16 | if ($test[0] eq "config") { |
| 17 | shift(@test); |
| 18 | $obj->config(@test); |
| 19 | return (); |
| 20 | } |
| 21 | |
| 22 | my $err = $obj->parse(@test); |
| 23 | if ($err) { |
| 24 | return $obj->err(); |
| 25 | } else { |
| 26 | my $d1 = $obj->value(); |
| 27 | return $d1; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | my($currS,$currMN,$currH,$currD,$currM,$currY)=("45","30","12","21","01","2000"); |
| 32 | |
| 33 | my $now = "${currY}${currM}${currD}${currH}:${currMN}:${currS}"; |
| 34 | my $today = "${currY}${currM}${currD}00:00:00"; |
| 35 | my $yesterdaydate = "${currY}${currM}". ${currD}-1; |
| 36 | my $tomorrowdate = "${currY}${currM}". ${currD}+1; |
| 37 | my $yesterday = "${yesterdaydate}00:00:00"; |
| 38 | my $tomorrow = "${tomorrowdate}00:00:00"; |
| 39 | |
| 40 | my $tests=" |
| 41 | |
| 42 | '5-3-2009 5:30 du soir' => 2009030517:30:00 |
| 43 | |
| 44 | '5-3-2009 a 5:30 du soir' => 2009030517:30:00 |
| 45 | |
| 46 | '5-3-2009 a 5:30:45 du soir' => 2009030517:30:45 |
| 47 | |
| 48 | '5-3-2009 a 5h30:45 du soir' => 2009030517:30:45 |
| 49 | |
| 50 | aujourd'hui => $today |
| 51 | |
| 52 | maintenant => $now |
| 53 | |
| 54 | hier => $yesterday |
| 55 | |
| 56 | demain => $tomorrow |
| 57 | |
| 58 | 'dernier mar en Juin 96' => 1996062500:00:00 |
| 59 | |
| 60 | 'dernier mar de Juin' => ${currY}062700:00:00 |
| 61 | |
| 62 | 'premier mar de Juin 1996' => 1996060400:00:00 |
| 63 | |
| 64 | 'premier mar de Juin' => ${currY}060600:00:00 |
| 65 | |
| 66 | '3e mardi de Juin 96' => 1996061800:00:00 |
| 67 | |
| 68 | '3e mardi de Juin 96 a 12:00' => 1996061812:00:00 |
| 69 | |
| 70 | '3e mardi de Juin 96 a 10:30 du matin' => 1996061810:30:00 |
| 71 | |
| 72 | '3e mardi de Juin 96 a 10:30 du soir' => 1996061822:30:00 |
| 73 | |
| 74 | |
| 75 | 'SepT 10 65' => 1965091000:00:00 |
| 76 | |
| 77 | 'SepT 10 1965' => 1965091000:00:00 |
| 78 | |
| 79 | 'Septembre 10 65' => 1965091000:00:00 |
| 80 | |
| 81 | 'Septembre 10 1965' => 1965091000:00:00 |
| 82 | |
| 83 | 'Septembre10 1965' => 1965091000:00:00 |
| 84 | |
| 85 | 'Septembre10 1965 12:00' => 1965091012:00:00 |
| 86 | |
| 87 | 'Septembre-10-1965 12:00' => 1965091012:00:00 |
| 88 | |
| 89 | 'Septembre/10/1965 12:00' => 1965091012:00:00 |
| 90 | |
| 91 | '12:00 Septembre10 1965' => 1965091012:00:00 |
| 92 | |
| 93 | '12:00 Septembre-10-1965' => 1965091012:00:00 |
| 94 | |
| 95 | '10 SepT 65' => 1965091000:00:00 |
| 96 | |
| 97 | '10 SepT 1965' => 1965091000:00:00 |
| 98 | |
| 99 | '10 Septembre 65' => 1965091000:00:00 |
| 100 | |
| 101 | '10 Septembre 1965' => 1965091000:00:00 |
| 102 | |
| 103 | 10SepT65 => 1965091000:00:00 |
| 104 | |
| 105 | 10SepT1965 => 1965091000:00:00 |
| 106 | |
| 107 | 10Septembre65 => 1965091000:00:00 |
| 108 | |
| 109 | '10Septembre 1965' => 1965091000:00:00 |
| 110 | |
| 111 | 'SepT 10 4:50' => ${currY}091004:50:00 |
| 112 | |
| 113 | 'Septembre 10 4:50' => ${currY}091004:50:00 |
| 114 | |
| 115 | 'SepT 10 4:50:40' => ${currY}091004:50:40 |
| 116 | |
| 117 | 'Septembre 10 4:50:42' => ${currY}091004:50:42 |
| 118 | |
| 119 | '10 SepT 4:50' => ${currY}091004:50:00 |
| 120 | |
| 121 | '10 Septembre 4:50' => ${currY}091004:50:00 |
| 122 | |
| 123 | '10SepT 4:50' => ${currY}091004:50:00 |
| 124 | |
| 125 | '10Septembre 4:50' => ${currY}091004:50:00 |
| 126 | |
| 127 | '10 SepT 4:50:51' => ${currY}091004:50:51 |
| 128 | |
| 129 | '10 Septembre 4:50:52' => ${currY}091004:50:52 |
| 130 | |
| 131 | '10SepT 4:50:53' => ${currY}091004:50:53 |
| 132 | |
| 133 | '10Septembre 4:50:54' => ${currY}091004:50:54 |
| 134 | |
| 135 | '10Septembre95 4:50:54' => 1995091004:50:54 |
| 136 | |
| 137 | 'Sept1065 4:50:53' => 1965091004:50:53 |
| 138 | |
| 139 | 'Sept101965 4:50:53' => 1965091004:50:53 |
| 140 | |
| 141 | '4:50 SepT 10' => ${currY}091004:50:00 |
| 142 | |
| 143 | '4:50 Septembre 10' => ${currY}091004:50:00 |
| 144 | |
| 145 | '4:50:40 SepT 10' => ${currY}091004:50:40 |
| 146 | |
| 147 | '4:50:42 Septembre 10' => ${currY}091004:50:42 |
| 148 | |
| 149 | '4:50 10 SepT' => ${currY}091004:50:00 |
| 150 | |
| 151 | '4:50 10 Septembre' => ${currY}091004:50:00 |
| 152 | |
| 153 | '4:50 10SepT' => ${currY}091004:50:00 |
| 154 | |
| 155 | '4:50 10Septembre' => ${currY}091004:50:00 |
| 156 | |
| 157 | '4:50:51 10 SepT' => ${currY}091004:50:51 |
| 158 | |
| 159 | '4:50:52 10 Septembre' => ${currY}091004:50:52 |
| 160 | |
| 161 | '4:50:53 10SepT' => ${currY}091004:50:53 |
| 162 | |
| 163 | '4:50:54 10Septembre' => ${currY}091004:50:54 |
| 164 | |
| 165 | 'SepT 1 5:30' => ${currY}090105:30:00 |
| 166 | |
| 167 | 'SepT 10 05:30' => ${currY}091005:30:00 |
| 168 | |
| 169 | 'SepT 10 05:30:11' => ${currY}091005:30:11 |
| 170 | |
| 171 | 'SepT 1 65' => 1965090100:00:00 |
| 172 | |
| 173 | 'SepT 1 1965' => 1965090100:00:00 |
| 174 | |
| 175 | 'Septembre 1 5:30' => ${currY}090105:30:00 |
| 176 | |
| 177 | 'Septembre 10 05:30' => ${currY}091005:30:00 |
| 178 | |
| 179 | 'Septembre 10 05h30:12' => ${currY}091005:30:12 |
| 180 | |
| 181 | 'Septembre 1 65' => 1965090100:00:00 |
| 182 | |
| 183 | 'Septembre 1 1965' => 1965090100:00:00 |
| 184 | |
| 185 | '5:30 SepT 1' => ${currY}090105:30:00 |
| 186 | |
| 187 | '05:30 SepT 10' => ${currY}091005:30:00 |
| 188 | |
| 189 | '05:30:11 SepT 10' => ${currY}091005:30:11 |
| 190 | |
| 191 | '5:30 Septembre 1' => ${currY}090105:30:00 |
| 192 | |
| 193 | '05:30 Septembre 10' => ${currY}091005:30:00 |
| 194 | |
| 195 | '05:30:12 du matin Septembre 10' => ${currY}091005:30:12 |
| 196 | |
| 197 | '05:30:12 du soir Septembre 10' => ${currY}091017:30:12 |
| 198 | |
| 199 | '1 SepT 65' => 1965090100:00:00 |
| 200 | |
| 201 | '1 SepT 1965' => 1965090100:00:00 |
| 202 | |
| 203 | '1 Septembre 65' => 1965090100:00:00 |
| 204 | |
| 205 | '1 Septembre 1965' => 1965090100:00:00 |
| 206 | |
| 207 | '1 12 65' => 1965120100:00:00 |
| 208 | |
| 209 | '1 12 1965' => 1965120100:00:00 |
| 210 | |
| 211 | '29 2 92' => 1992022900:00:00 |
| 212 | |
| 213 | '2 29 92' => '[parse] Invalid date' |
| 214 | |
| 215 | '2 29 90' => '[parse] Invalid date' |
| 216 | |
| 217 | '1er SepT 65' => 1965090100:00:00 |
| 218 | |
| 219 | 'SepT premier 1965' => 1965090100:00:00 |
| 220 | |
| 221 | 'Fevrier 3, 2002' => 2002020300:00:00 |
| 222 | |
| 223 | 'FEVRIER 3, 2002' => 2002020300:00:00 |
| 224 | |
| 225 | 'FÉVRIER 3, 2002' => 2002020300:00:00 |
| 226 | |
| 227 | 'f\xE9vrier 3, 2002' => 2002020300:00:00 |
| 228 | |
| 229 | 'f\x{e9}vrier 3, 2002' => 2002020300:00:00 |
| 230 | |
| 231 | "; |
| 232 | |
| 233 | $::ti->tests(func => \&test, |
| 234 | tests => $tests); |
| 235 | $::ti->done_testing(); |
| 236 | |
| 237 | #Local Variables: |
| 238 | #mode: cperl |
| 239 | #indent-tabs-mode: nil |
| 240 | #cperl-indent-level: 3 |
| 241 | #cperl-continued-statement-offset: 2 |
| 242 | #cperl-continued-brace-offset: 0 |
| 243 | #cperl-brace-offset: 0 |
| 244 | #cperl-brace-imaginary-offset: 0 |
| 245 | #cperl-label-offset: 0 |
| 246 | #End: |