| 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 | my($d1,$d2) = (@_); |
| 11 | DateCalc($d1,$d2); |
| 12 | } |
| 13 | |
| 14 | Date_Init("ForceDate=1997-03-08-12:30:00,America/New_York"); |
| 15 | Date_Init("ConfigFile=Manip.cnf"); |
| 16 | |
| 17 | my $tests=" |
| 18 | |
| 19 | # Exact deltas |
| 20 | |
| 21 | 'Wed Feb 7 1996 8:00' +1:1:1:1 => 1996020809:01:01 |
| 22 | |
| 23 | 'Wed Nov 20 1996 noon' +0:5:0:0 => 1996112017:00:00 |
| 24 | |
| 25 | 'Wed Nov 20 1996 noon' +0:13:0:0 => 1996112101:00:00 |
| 26 | |
| 27 | 'Wed Nov 20 1996 noon' +3:2:0:0 => 1996112314:00:00 |
| 28 | |
| 29 | 'Wed Nov 20 1996 noon' -3:2:0:0 => 1996111710:00:00 |
| 30 | |
| 31 | 'Wed Nov 20 1996 noon' +3:13:0:0 => 1996112401:00:00 |
| 32 | |
| 33 | 'Wed Nov 20 1996 noon' +6:2:0:0 => 1996112614:00:00 |
| 34 | |
| 35 | 'Dec 31 1996 noon' +1:2:0:0 => 1997010114:00:00 |
| 36 | |
| 37 | 'Jan 31 1997 23:59:59' '+ 1 sec' => 1997020100:00:00 |
| 38 | |
| 39 | '20050215 13:59:11' -10h => 2005021503:59:11 |
| 40 | |
| 41 | 2005021513:59:11 '-10h +0s' => 2005021503:59:11 |
| 42 | |
| 43 | # Approx deltas |
| 44 | |
| 45 | 'Wed Feb 7 1996 8:00' +1:1:1:1 => 1996020809:01:01 |
| 46 | |
| 47 | 'Wed Nov 20 1996 noon' +0:5:0:0 => 1996112017:00:00 |
| 48 | |
| 49 | 'Wed Nov 20 1996 noon' +0:13:0:0 => 1996112101:00:00 |
| 50 | |
| 51 | 'Wed Nov 20 1996 noon' +3:2:0:0 => 1996112314:00:00 |
| 52 | |
| 53 | 'Wed Nov 20 1996 noon' -3:2:0:0 => 1996111710:00:00 |
| 54 | |
| 55 | 'Wed Nov 20 1996 noon' +3:13:0:0 => 1996112401:00:00 |
| 56 | |
| 57 | 'Wed Nov 20 1996 noon' +6:2:0:0 => 1996112614:00:00 |
| 58 | |
| 59 | 'Dec 31 1996 noon' +1:2:0:0 => 1997010114:00:00 |
| 60 | |
| 61 | 'Jan 31 1997 23:59:59' '+ 1 sec' => 1997020100:00:00 |
| 62 | |
| 63 | # Business deltas |
| 64 | |
| 65 | 'Wed Nov 20 1996 noon' '+0:5:0:0 business' => 1996112108:00:00 |
| 66 | |
| 67 | 'Wed Nov 20 1996 noon' '+0:2:0:0 business' => 1996112014:00:00 |
| 68 | |
| 69 | 'Wed Nov 20 1996 noon' '+3:2:0:0 business' => 1996112514:00:00 |
| 70 | |
| 71 | 'Wed Nov 20 1996 noon' '-3:2:0:0 business' => 1996111510:00:00 |
| 72 | |
| 73 | 'Wed Nov 20 1996 noon' '+3:7:0:0 business' => 1996112610:00:00 |
| 74 | |
| 75 | 'Wed Nov 20 1996 noon' '+6:2:0:0 business' => 1996120214:00:00 |
| 76 | |
| 77 | 'Dec 31 1996 noon' '+1:2:0:0 business' => 1997010214:00:00 |
| 78 | |
| 79 | 'Dec 30 1996 noon' '+1:2:0:0 business' => 1996123114:00:00 |
| 80 | |
| 81 | 'Mar 31 1997 16:59:59' '+ 1 sec' => 1997033117:00:00 |
| 82 | |
| 83 | 'Mar 31 1997 16:59:59' '+ 1 sec business' => 1997040108:00:00 |
| 84 | |
| 85 | 'Wed Nov 20 1996 noon' +0:0:1:0:0:0:0 => 1996112712:00:00 |
| 86 | |
| 87 | 2002120600:00:00 '- business 4 hours' => 2002120513:00:00 |
| 88 | |
| 89 | 2002120600:00:01 '- business 4 hours' => 2002120513:00:00 |
| 90 | |
| 91 | 2002120523:59:59 '- business 4 hours' => 2002120513:00:00 |
| 92 | |
| 93 | 2002120602:00:00 '- business 4 hours' => 2002120513:00:00 |
| 94 | |
| 95 | 2002120609:00:00 '- business 4 hours' => 2002120514:00:00 |
| 96 | |
| 97 | 2002120609:00:10 '- business 4 hours' => 2002120514:00:10 |
| 98 | |
| 99 | 2002120611:00:00 '- business 4 hours' => 2002120516:00:00 |
| 100 | |
| 101 | 2002120612:00:00 '- business 4 hours' => 2002120608:00:00 |
| 102 | |
| 103 | 2002120512:00:00 '+ business 4 hours' => 2002120516:00:00 |
| 104 | |
| 105 | 2002120514:00:00 '+ business 4 hours' => 2002120609:00:00 |
| 106 | |
| 107 | 2002120522:00:00 '+ business 4 hours' => 2002120612:00:00 |
| 108 | |
| 109 | 2002120523:59:59 '+ business 4 hours' => 2002120612:00:00 |
| 110 | |
| 111 | 2002120602:00:00 '+ business 4 hours' => 2002120612:00:00 |
| 112 | |
| 113 | 2002120609:00:00 '+ business 4 hours' => 2002120613:00:00 |
| 114 | |
| 115 | 20060616 '+1 business day' => 2006061908:00:00 |
| 116 | |
| 117 | "; |
| 118 | |
| 119 | $::ti->tests(func => \&test, |
| 120 | tests => $tests); |
| 121 | $::ti->done_testing(); |
| 122 | |
| 123 | #Local Variables: |
| 124 | #mode: cperl |
| 125 | #indent-tabs-mode: nil |
| 126 | #cperl-indent-level: 3 |
| 127 | #cperl-continued-statement-offset: 2 |
| 128 | #cperl-continued-brace-offset: 0 |
| 129 | #cperl-brace-offset: 0 |
| 130 | #cperl-brace-imaginary-offset: 0 |
| 131 | #cperl-label-offset: 0 |
| 132 | #End: |