| 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 | sub test { |
| 10 | return ParseDateDelta(@_); |
| 11 | } |
| 12 | |
| 13 | Date_Init("ForceDate=1997-03-08-12:30:00,America/New_York"); |
| 14 | |
| 15 | my $tests=" |
| 16 | |
| 17 | # Test weeks |
| 18 | |
| 19 | '+ 4 week 3 day' => 0:0:4:3:0:0:0 |
| 20 | |
| 21 | '+ 4 wk 3 day 20:30' => __blank__ |
| 22 | |
| 23 | '+ 15mn' => 0:0:0:0:0:15:0 |
| 24 | |
| 25 | '+ 15 mn' => 0:0:0:0:0:15:0 |
| 26 | |
| 27 | '15 mn' => 0:0:0:0:0:15:0 |
| 28 | |
| 29 | '+15 mn' => 0:0:0:0:0:15:0 |
| 30 | |
| 31 | +15mn => 0:0:0:0:0:15:0 |
| 32 | |
| 33 | '+ 35 y 10 month 15mn' => 35:10:0:0:0:15:0 |
| 34 | |
| 35 | '+ 35 y 10m 15mn' => 35:10:0:0:0:15:0 |
| 36 | |
| 37 | '+ 35year 10:0:0:0:15:0' => __blank__ |
| 38 | |
| 39 | '+ 35 y -10 month 15mn' => 34:2:0:0:0:-15:0 |
| 40 | |
| 41 | +35:-10:0:0:0:15:0 => 34:2:0:0:0:-15:0 |
| 42 | |
| 43 | '+ 35 y10 month12:40' => __blank__ |
| 44 | |
| 45 | '+35 y 10 month 1:12:40' => __blank__ |
| 46 | |
| 47 | '+35x 10 month' => __blank__ |
| 48 | |
| 49 | '+ 35 y -10 month 1:12:40' => __blank__ |
| 50 | |
| 51 | 1:2:3:4:5:6:7 => 1:2:3:4:5:6:7 |
| 52 | |
| 53 | 'in 1:2:3:4:5:6:7' => __blank__ |
| 54 | |
| 55 | '1:2:3:4:5:6:7 ago' => __blank__ |
| 56 | |
| 57 | -1:2:3:4:5:6:7 => -1:2:3:4:5:6:7 |
| 58 | |
| 59 | -1::3:4:5:6:7 => -1:0:3:4:5:6:7 |
| 60 | |
| 61 | '1::3:4:5:6:7 ago' => __blank__ |
| 62 | |
| 63 | # Test normalization of deltas |
| 64 | |
| 65 | +1:+1:+1:+1 => 0:0:0:1:1:1:1 |
| 66 | |
| 67 | +1:+1:+1:-1 => 0:0:0:1:1:0:59 |
| 68 | |
| 69 | +1:+1:-1:+1 => 0:0:0:1:0:59:1 |
| 70 | |
| 71 | +1:-1:+1:+1 => 0:0:0:0:23:1:1 |
| 72 | |
| 73 | +1:+1:-1:-1 => 0:0:0:1:0:58:59 |
| 74 | |
| 75 | +1:-1:+1:-1 => 0:0:0:0:23:0:59 |
| 76 | |
| 77 | +1:-1:-1:+1 => 0:0:0:0:22:59:1 |
| 78 | |
| 79 | -0:1:+0:0:0:0:0 => 0:-1:0:0:0:0:0 |
| 80 | |
| 81 | -0:0:1:+0:-0:0:0 => 0:0:-1:0:0:0:0 |
| 82 | |
| 83 | 0:0:0:0:9491:54:0 => 0:0:0:0:9491:54:0 |
| 84 | |
| 85 | 0:0:0:0:9491:54:0 semi => 0:0:56:3:11:54:0 |
| 86 | |
| 87 | "; |
| 88 | |
| 89 | $::ti->tests(func => \&test, |
| 90 | tests => $tests); |
| 91 | $::ti->done_testing(); |
| 92 | |
| 93 | #Local Variables: |
| 94 | #mode: cperl |
| 95 | #indent-tabs-mode: nil |
| 96 | #cperl-indent-level: 3 |
| 97 | #cperl-continued-statement-offset: 2 |
| 98 | #cperl-continued-brace-offset: 0 |
| 99 | #cperl-brace-offset: 0 |
| 100 | #cperl-brace-imaginary-offset: 0 |
| 101 | #cperl-label-offset: 0 |
| 102 | #End: |