| 1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
use warnings; |
| 4 |
use strict; |
| 5 |
use Test::Inter; |
| 6 |
$::ti = new Test::Inter $0; |
| 7 |
require "tests-dm5.pl"; |
| 8 |
|
| 9 |
Date_Init("TZ=EST"); |
| 10 |
Date_Init("ForceDate=1997-03-08-12:30:00"); |
| 11 |
Date_Init("Language=Romanian","DateFormat=US","Internal=0"); |
| 12 |
|
| 13 |
my($currS,$currMN,$currH,$currD,$currM,$currY)=("00","30","12","08","03","1997"); |
| 14 |
|
| 15 |
my $today ="$currY$currM$currD$currH:$currMN:$currS"; |
| 16 |
my $todaydate ="$currY$currM$currD"; |
| 17 |
my $yesterdaydate="$currY$currM". $currD-1; |
| 18 |
my $tomorrowdate ="$currY$currM". $currD+1; |
| 19 |
my $yesterday ="$yesterdaydate$currH:$currMN:$currS"; |
| 20 |
my $tomorrow ="$tomorrowdate$currH:$currMN:$currS"; |
| 21 |
|
| 22 |
my $tests=" |
| 23 |
|
| 24 |
# Test built in strings like today and yesterday. A few may fail on a |
| 25 |
# slow computer. On the 1st or last day of the month, the |
| 26 |
# yesterday/today test will fail because of the simplicity of the |
| 27 |
# test. |
| 28 |
|
| 29 |
acum => $today |
| 30 |
|
| 31 |
astazi => $today |
| 32 |
|
| 33 |
ieri => $yesterday |
| 34 |
|
| 35 |
miine => $tomorrow |
| 36 |
|
| 37 |
|
| 38 |
'astazi la 4:00' => ${todaydate}04:00:00 |
| 39 |
|
| 40 |
'astazi la 4:00 pm' => ${todaydate}16:00:00 |
| 41 |
|
| 42 |
'astazi la 16:00:00' => ${todaydate}16:00:00 |
| 43 |
|
| 44 |
'astazi la 12:00 am' => ${todaydate}00:00:00 |
| 45 |
|
| 46 |
'astazi la 12:00 GMT' => ${todaydate}07:00:00 |
| 47 |
|
| 48 |
'astazi la 4:00 PST' => ${todaydate}07:00:00 |
| 49 |
|
| 50 |
'astazi la 4:00 -0800' => ${todaydate}07:00:00 |
| 51 |
|
| 52 |
'astazi la amiaza' => ${todaydate}12:00:00 |
| 53 |
|
| 54 |
'miine la amiaza ' => ${tomorrowdate}12:00:00 |
| 55 |
|
| 56 |
'1 luna in urma ' => 1997020812:30:00 |
| 57 |
|
| 58 |
# Test weeks |
| 59 |
|
| 60 |
'a 22-a duminica' => 1997060100:00:00 |
| 61 |
|
| 62 |
1997023 => 1997012300:00:00 |
| 63 |
|
| 64 |
1997035 => 1997020400:00:00 |
| 65 |
|
| 66 |
97-035 => 1997020400:00:00 |
| 67 |
|
| 68 |
97035 => 1997020400:00:00 |
| 69 |
|
| 70 |
'a douazecisidoua duminica 1996' => 1996060200:00:00 |
| 71 |
|
| 72 |
'22 duminica in 1996' => 1996060200:00:00 |
| 73 |
|
| 74 |
'a 22-a duminica 12:00' => 1997060112:00:00 |
| 75 |
|
| 76 |
'a 22-a duminica la 12:00' => 1997060112:00:00 |
| 77 |
|
| 78 |
'a 22-a duminica la 12:00 EST' => 1997060112:00:00 |
| 79 |
|
| 80 |
'a 22-a duminica in 1996 la 12:00 EST' => 1996060212:00:00 |
| 81 |
|
| 82 |
'duminica saptamina 1 1999' => 1999011000:00:00 |
| 83 |
|
| 84 |
'joi saptamina 0 1999' => 1998123100:00:00 |
| 85 |
|
| 86 |
'prima joi in 1999' => 1999010700:00:00 |
| 87 |
|
| 88 |
'prima duminica in 1999' => 1999010300:00:00 |
| 89 |
|
| 90 |
'duminica saptamina 22' => 1997060100:00:00 |
| 91 |
|
| 92 |
'duminica saptamina a douazecisidoua 1996' => 1996060200:00:00 |
| 93 |
|
| 94 |
'duminica sapt 22 in 1996' => 1996060200:00:00 |
| 95 |
|
| 96 |
'duminica saptamina 22 12:00' => 1997060112:00:00 |
| 97 |
|
| 98 |
'duminica saptamina 22 12:00' => 1997060112:00:00 |
| 99 |
|
| 100 |
'duminica saptamina 22 la 12:00 EST' => 1997060112:00:00 |
| 101 |
|
| 102 |
'duminica saptamina 22 in 1996 la 12:00 EST' => 1996060212:00:00 |
| 103 |
|
| 104 |
'duminica 22 saptamini ' => 1997060100:00:00 |
| 105 |
|
| 106 |
'duminica a douazecisidoua saptamina 1996' => 1996060200:00:00 |
| 107 |
|
| 108 |
'duminica 22 sapt in 1996' => 1996060200:00:00 |
| 109 |
|
| 110 |
'duminica saptamina 22 12:00' => 1997060112:00:00 |
| 111 |
|
| 112 |
'duminica saptamina 22 la 12:00' => 1997060112:00:00 |
| 113 |
|
| 114 |
'duminica saptamina 22 la 12:00 EST' => 1997060112:00:00 |
| 115 |
|
| 116 |
'duminica saptamina 22 in 1996 la 12:00 EST' => 1996060212:00:00 |
| 117 |
|
| 118 |
# Tests 'which day in mon' formats |
| 119 |
|
| 120 |
'ultima marti in iun 96' => 1996062500:00:00 |
| 121 |
|
| 122 |
'ultima marti din iunie' => 1997062400:00:00 |
| 123 |
|
| 124 |
'prima marti in iun 1996' => 1996060400:00:00 |
| 125 |
|
| 126 |
'prima marti in iunie' => 1997060300:00:00 |
| 127 |
|
| 128 |
'a 3-a marti in iun 96' => 1996061800:00:00 |
| 129 |
|
| 130 |
'a 3-a marti in iun 96 la 12:00:00' => 1996061812:00:00 |
| 131 |
|
| 132 |
'a 3-a marti in iun 96 la 10:30am' => 1996061810:30:00 |
| 133 |
|
| 134 |
'a 3-a marti in iun 96 la 10:30 pm' => 1996061822:30:00 |
| 135 |
|
| 136 |
'a 3-a marti in iun 96 la 10:30 pm GMT' => 1996061817:30:00 |
| 137 |
|
| 138 |
'a 3-a marti in iun 96 la 10:30 pm CET' => 1996061816:30:00 |
| 139 |
|
| 140 |
# Tests Date Time Date%Time Date=mm%dd '12/10/65 la 5:30:25' => |
| 141 |
# 1965121005:30:25 |
| 142 |
|
| 143 |
'12-10-65 la 5:30:25' => 1965121005:30:25 |
| 144 |
|
| 145 |
'12 10 65 la 5:30:25' => 1965121005:30:25 |
| 146 |
|
| 147 |
'12 10 1965 la 5:30:25' => 1965121005:30:25 |
| 148 |
|
| 149 |
'12.10.1965 05:61' => '' |
| 150 |
|
| 151 |
'12.10.1965 05:30:61' => '' |
| 152 |
|
| 153 |
12/10 => ${currY}121000:00:00 |
| 154 |
|
| 155 |
'12/10 05:30' => ${currY}121005:30:00 |
| 156 |
|
| 157 |
'12/10 la 05:30:25' => ${currY}121005:30:25 |
| 158 |
|
| 159 |
'12/10 la 05:30:25 GMT' => ${currY}121000:30:25 |
| 160 |
|
| 161 |
'12/10 5:30' => ${currY}121005:30:00 |
| 162 |
|
| 163 |
'12/10 05:30' => ${currY}121005:30:00 |
| 164 |
|
| 165 |
'12-10 5:30' => ${currY}121005:30:00 |
| 166 |
|
| 167 |
'12.10 05:30' => ${currY}121005:30:00 |
| 168 |
|
| 169 |
'12 10 05:30' => ${currY}121005:30:00 |
| 170 |
|
| 171 |
'2 29 92' => 1992022900:00:00 |
| 172 |
|
| 173 |
'2 29 90' => '' |
| 174 |
|
| 175 |
# Tests Date Time |
| 176 |
# Date%Time |
| 177 |
# Date=mmm%dd |
| 178 |
|
| 179 |
Dec/10/1965 => 1965121000:00:00 |
| 180 |
|
| 181 |
Decembrie/10/65 => 1965121000:00:00 |
| 182 |
|
| 183 |
Dec-10-65 => 1965121000:00:00 |
| 184 |
|
| 185 |
'Dec 10 65' => 1965121000:00:00 |
| 186 |
|
| 187 |
'DecEMBRIE10 65' => 1965121000:00:00 |
| 188 |
|
| 189 |
'Decembrie/10/65 5:30:25' => 1965121005:30:25 |
| 190 |
|
| 191 |
'Dec/10/65/5:30 pm' => 1965121017:30:00 |
| 192 |
|
| 193 |
'Dec/10/65/5:30 pm GMT' => 1965121012:30:00 |
| 194 |
|
| 195 |
'Dec/10/65 la 5:30:25' => 1965121005:30:25 |
| 196 |
|
| 197 |
'Dec-10-1965 5:30:25' => 1965121005:30:25 |
| 198 |
|
| 199 |
'Decembrie-10-65 5:30:25' => 1965121005:30:25 |
| 200 |
|
| 201 |
'Dec-10-65-5:30 pm' => 1965121017:30:00 |
| 202 |
|
| 203 |
'Dec-10-65 la 5:30:25' => 1965121005:30:25 |
| 204 |
|
| 205 |
'Dec 10 65 5:30:25' => 1965121005:30:25 |
| 206 |
|
| 207 |
'Dec 10 65 5:30 pm' => 1965121017:30:00 |
| 208 |
|
| 209 |
'Decembrie 10 65 la 5:30:25' => 1965121005:30:25 |
| 210 |
|
| 211 |
'Dec 10 1965 la 5:30:25' => 1965121005:30:25 |
| 212 |
|
| 213 |
'Dec-10-1965 05:61' => '' |
| 214 |
|
| 215 |
'Dec-10-1965 05:30:61' => '' |
| 216 |
|
| 217 |
Decembrie/10 => ${currY}121000:00:00 |
| 218 |
|
| 219 |
'Dec/10 05:30' => ${currY}121005:30:00 |
| 220 |
|
| 221 |
'Dec/10 la 05:30:25' => ${currY}121005:30:25 |
| 222 |
|
| 223 |
'Dec/10 la 05:30:25 GMT' => ${currY}121000:30:25 |
| 224 |
|
| 225 |
'Dec/10 5:30' => ${currY}121005:30:00 |
| 226 |
|
| 227 |
'Dec/10 05:30' => ${currY}121005:30:00 |
| 228 |
|
| 229 |
'Dec-10 5:30' => ${currY}121005:30:00 |
| 230 |
|
| 231 |
'Dec-10 05:30' => ${currY}121005:30:00 |
| 232 |
|
| 233 |
'Decembrie10 05:30' => ${currY}121005:30:00 |
| 234 |
|
| 235 |
'DeC intii 1965' => 1965120100:00:00 |
| 236 |
|
| 237 |
# Tests Date Time |
| 238 |
# Date%Time |
| 239 |
# Date=dd%mmm |
| 240 |
|
| 241 |
10/Dec/1965 => 1965121000:00:00 |
| 242 |
|
| 243 |
10/Decembrie/65 => 1965121000:00:00 |
| 244 |
|
| 245 |
10-Dec-65 => 1965121000:00:00 |
| 246 |
|
| 247 |
'10 Dec 65' => 1965121000:00:00 |
| 248 |
|
| 249 |
'10/Decembrie/65 5:30:25' => 1965121005:30:25 |
| 250 |
|
| 251 |
'10/Dec/65/5:30 pm' => 1965121017:30:00 |
| 252 |
|
| 253 |
'10/Dec/65/5:30 pm GMT' => 1965121012:30:00 |
| 254 |
|
| 255 |
'10/Dec/65 la 5:30:25' => 1965121005:30:25 |
| 256 |
|
| 257 |
'10-Dec-1965 5:30:25' => 1965121005:30:25 |
| 258 |
|
| 259 |
'10-Decembrie-65 5:30:25' => 1965121005:30:25 |
| 260 |
|
| 261 |
'10-Dec-65-5:30 pm' => 1965121017:30:00 |
| 262 |
|
| 263 |
'10-Dec-65 la 5:30:25' => 1965121005:30:25 |
| 264 |
|
| 265 |
'10 Dec 65 5:30:25' => 1965121005:30:25 |
| 266 |
|
| 267 |
'10 Dec 65 5:30 pm' => 1965121017:30:00 |
| 268 |
|
| 269 |
'10Decembrie 65 la 5:30:25' => 1965121005:30:25 |
| 270 |
|
| 271 |
'10 Dec 1965 la 5:30:25' => 1965121005:30:25 |
| 272 |
|
| 273 |
'10Dec 1965 la 5:30:25' => 1965121005:30:25 |
| 274 |
|
| 275 |
'10 Dec1965 la 5:30:25' => 1965121005:30:25 |
| 276 |
|
| 277 |
'10Dec1965 la 5:30:25' => 1965121005:30:25 |
| 278 |
|
| 279 |
'10-Dec-1965 05:61' => '' |
| 280 |
|
| 281 |
'10-Dec-1965 05:30:61' => '' |
| 282 |
|
| 283 |
10/Decembrie => ${currY}121000:00:00 |
| 284 |
|
| 285 |
'10/Dec 05:30' => ${currY}121005:30:00 |
| 286 |
|
| 287 |
'10/Dec la 05:30:25' => ${currY}121005:30:25 |
| 288 |
|
| 289 |
'10-Dec la 05:30:25 GMT' => ${currY}121000:30:25 |
| 290 |
|
| 291 |
'10-Dec 5:30' => ${currY}121005:30:00 |
| 292 |
|
| 293 |
'10/Dec 05:30' => ${currY}121005:30:00 |
| 294 |
|
| 295 |
'10Decembrie 05:30' => ${currY}121005:30:00 |
| 296 |
|
| 297 |
'Intii DeC 65' => 1965120100:00:00 |
| 298 |
|
| 299 |
# Tests time only formats 5:30 => ${todaydate}05:30:00 |
| 300 |
|
| 301 |
5:30:02 => ${todaydate}05:30:02 |
| 302 |
|
| 303 |
15:30:00 => ${todaydate}15:30:00 |
| 304 |
|
| 305 |
# Tests TimeDate Time%Date '5:30 pm 12/10/65' => 1965121017:30:00 |
| 306 |
|
| 307 |
'5:30 pm GMT 12/10/65' => 1965121012:30:00 |
| 308 |
|
| 309 |
5:30:25/12/10/65 => 1965121005:30:25 |
| 310 |
|
| 311 |
'5:30:25 12-10-1965' => 1965121005:30:25 |
| 312 |
|
| 313 |
'5:30:25 12-10-65' => 1965121005:30:25 |
| 314 |
|
| 315 |
'5:30 pm 12-10-65' => 1965121017:30:00 |
| 316 |
|
| 317 |
5:30:25/12-10-65 => 1965121005:30:25 |
| 318 |
|
| 319 |
'5:30:25 12 10 65' => 1965121005:30:25 |
| 320 |
|
| 321 |
'5:30 pm 12 10 65' => 1965121017:30:00 |
| 322 |
|
| 323 |
'5:30 pm GMT 12 10 65' => 1965121012:30:00 |
| 324 |
|
| 325 |
'5:30:25 12 10 1965' => 1965121005:30:25 |
| 326 |
|
| 327 |
'05:61 12-10-1965' => '' |
| 328 |
|
| 329 |
'05:30:61 12-10-1965' => '' |
| 330 |
|
| 331 |
'05:30 12/10' => ${currY}121005:30:00 |
| 332 |
|
| 333 |
05:30/12/10 => ${currY}121005:30:00 |
| 334 |
|
| 335 |
'05:30:25 12/10' => ${currY}121005:30:25 |
| 336 |
|
| 337 |
05:30:25/12-10 => ${currY}121005:30:25 |
| 338 |
|
| 339 |
'05:30:25 GMT 12/10' => ${currY}121000:30:25 |
| 340 |
|
| 341 |
'5:30 12/10' => ${currY}121005:30:00 |
| 342 |
|
| 343 |
'05:30 12/10' => ${currY}121005:30:00 |
| 344 |
|
| 345 |
'5:30 12-10' => ${currY}121005:30:00 |
| 346 |
|
| 347 |
'05:30 12-10' => ${currY}121005:30:00 |
| 348 |
|
| 349 |
'05:30 12 10' => ${currY}121005:30:00 |
| 350 |
|
| 351 |
# Tests TimeDate |
| 352 |
# Time%Date |
| 353 |
# Date=mmm%dd, dd%mmm |
| 354 |
|
| 355 |
'4:50 DeC 10' => ${currY}121004:50:00 |
| 356 |
|
| 357 |
'4:50 DeCembrie 10' => ${currY}121004:50:00 |
| 358 |
|
| 359 |
'4:50:40 DeC 10' => ${currY}121004:50:40 |
| 360 |
|
| 361 |
'4:50:42 DeCembrie 10' => ${currY}121004:50:42 |
| 362 |
|
| 363 |
'4:50 10 DeC' => ${currY}121004:50:00 |
| 364 |
|
| 365 |
'4:50 10 DeCembrie' => ${currY}121004:50:00 |
| 366 |
|
| 367 |
'4:50 10DeC' => ${currY}121004:50:00 |
| 368 |
|
| 369 |
'4:50 10DeCembrie' => ${currY}121004:50:00 |
| 370 |
|
| 371 |
'4:50:51 10 DeC' => ${currY}121004:50:51 |
| 372 |
|
| 373 |
'4:50:52 10 DeCembrie' => ${currY}121004:50:52 |
| 374 |
|
| 375 |
'4:50:53 10DeC' => ${currY}121004:50:53 |
| 376 |
|
| 377 |
'4:50:54 10DeCembrie' => ${currY}121004:50:54 |
| 378 |
|
| 379 |
4:50:54DeCembrie10 => ${currY}121004:50:54 |
| 380 |
|
| 381 |
4:50:54DeCembrie10/65 => 1965121004:50:54 |
| 382 |
|
| 383 |
4:50:54DeCembrie1965 => 1965120104:50:54 |
| 384 |
|
| 385 |
'Sept 1995' => 1995090100:00:00 |
| 386 |
|
| 387 |
'1995 septembrie' => 1995090100:00:00 |
| 388 |
|
| 389 |
'5:30 DeC 1' => ${currY}120105:30:00 |
| 390 |
|
| 391 |
'05:30 DeC 10' => ${currY}121005:30:00 |
| 392 |
|
| 393 |
'05:30:11 DeC 10' => ${currY}121005:30:11 |
| 394 |
|
| 395 |
'5:30 DeCembrie 1' => ${currY}120105:30:00 |
| 396 |
|
| 397 |
'05:30 DeCembrie 10' => ${currY}121005:30:00 |
| 398 |
|
| 399 |
'05:30:12 DeCembrie 10' => ${currY}121005:30:12 |
| 400 |
|
| 401 |
# Test ctime formats 'DeCembrie 10 05:30:12 1996' => 1996121005:30:12 |
| 402 |
|
| 403 |
'DeC10 05:30:12 96' => 1996121005:30:12 |
| 404 |
|
| 405 |
# Test some tricky timezone conversions |
| 406 |
|
| 407 |
'Febr 28 1997 23:00-0900' => 1997030103:00:00 |
| 408 |
|
| 409 |
'Febr 27 1997 23:00-0900' => 1997022803:00:00 |
| 410 |
|
| 411 |
'Febr 01 1997 01:00-0100' => 1997013121:00:00 |
| 412 |
|
| 413 |
'Febr 02 1997 01:00-0100' => 1997020121:00:00 |
| 414 |
|
| 415 |
'Febr 02 1997 01:00+0100' => 1997020119:00:00 |
| 416 |
|
| 417 |
'Febr 02 1997 01:00+01' => 1997020119:00:00 |
| 418 |
|
| 419 |
'Febr 02 1997 01:00+01:00' => 1997020119:00:00 |
| 420 |
|
| 421 |
19970202010000+0100 => 1997020119:00:00 |
| 422 |
|
| 423 |
# More tests... 'ultima zi din octombrie 1997' => 1997103100:00:00 |
| 424 |
|
| 425 |
'epoch 400000' => 1970010510:06:40 |
| 426 |
|
| 427 |
'19980102030405 EST' => 1998010203:04:05 |
| 428 |
|
| 429 |
19980102030405E => 1998010203:04:05 |
| 430 |
|
| 431 |
'Luni, 19 ian 1998 08:11:34 +1030' => 1998011816:41:34 |
| 432 |
|
| 433 |
'Marti, 26 Mai 1998 13:23:15 -0500 (EST)' => 1998052613:23:15 |
| 434 |
|
| 435 |
Dec101965 => 1965121000:00:00 |
| 436 |
|
| 437 |
10Dec1965 => 1965121000:00:00 |
| 438 |
|
| 439 |
101965Dec => 1965121000:00:00 |
| 440 |
|
| 441 |
"; |
| 442 |
|
| 443 |
$::ti->tests(func => \&ParseDate, |
| 444 |
tests => $tests); |
| 445 |
$::ti->done_testing(); |
| 446 |
|
| 447 |
#Local Variables: |
| 448 |
#mode: cperl |
| 449 |
#indent-tabs-mode: nil |
| 450 |
#cperl-indent-level: 3 |
| 451 |
#cperl-continued-statement-offset: 2 |
| 452 |
#cperl-continued-brace-offset: 0 |
| 453 |
#cperl-brace-offset: 0 |
| 454 |
#cperl-brace-imaginary-offset: 0 |
| 455 |
#cperl-label-offset: 0 |
| 456 |
#End: |