| 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 | my $obj = new Date::Manip::Recur; |
| 10 | $obj->config("forcedate","2000-01-21-00:00:00,America/New_York"); |
| 11 | |
| 12 | sub test { |
| 13 | my($recur,$arg1,$arg2) = @_; |
| 14 | my $err = $obj->parse($recur); |
| 15 | if ($err) { |
| 16 | return $obj->err(); |
| 17 | } else { |
| 18 | my $start = undef; |
| 19 | my $end = undef; |
| 20 | if (defined($arg1)) { |
| 21 | $start = $obj->new_date(); |
| 22 | $start->parse($arg1); |
| 23 | } |
| 24 | if (defined($arg2)) { |
| 25 | $end = $obj->new_date(); |
| 26 | $end->parse($arg2); |
| 27 | } |
| 28 | my @dates = $obj->dates($start,$end); |
| 29 | $err = $obj->err(); |
| 30 | return $err if ($err); |
| 31 | my @ret = (); |
| 32 | foreach my $d (@dates) { |
| 33 | my $v = $d->value(); |
| 34 | push(@ret,$v); |
| 35 | } |
| 36 | return @ret; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | my $tests=" |
| 41 | |
| 42 | 1:2:3:4*12:30:00**2000010500:00:00*2000010100:00:00*2003010100:00:00 |
| 43 | => |
| 44 | 2000010512:30:00 |
| 45 | 2001033012:30:00 |
| 46 | 2002062412:30:00 |
| 47 | |
| 48 | 1:2:3:4*12:30:00**2000010500:00:00*2000010100:00:00*2003010100:00:00 |
| 49 | 2001010100:00:00 |
| 50 | => |
| 51 | 2001033012:30:00 |
| 52 | 2002062412:30:00 |
| 53 | |
| 54 | 1:2:3:4*12:30:00**2000010500:00:00*2000010100:00:00*2003010100:00:00 |
| 55 | __undef__ |
| 56 | 2001123100:00:00 |
| 57 | => |
| 58 | 2000010512:30:00 |
| 59 | 2001033012:30:00 |
| 60 | |
| 61 | 1:2:3:4*12:30:00**2000010500:00:00*2000010100:00:00*2003010100:00:00 |
| 62 | 2001010100:00:00 |
| 63 | 2001123100:00:00 |
| 64 | => |
| 65 | 2001033012:30:00 |
| 66 | |
| 67 | 1:2:3:4*12:30:00**2000010500:00:00 |
| 68 | 2000010100:00:00 |
| 69 | 2003010100:00:00 |
| 70 | => |
| 71 | 2000010512:30:00 |
| 72 | 2001033012:30:00 |
| 73 | 2002062412:30:00 |
| 74 | |
| 75 | ### Test new years definition |
| 76 | |
| 77 | 1*1:0:1:0:0:0*dwd**1999060100:00:00*2006060100:00:00 |
| 78 | => |
| 79 | 1999123100:00:00 |
| 80 | 2001010100:00:00 |
| 81 | 2002010100:00:00 |
| 82 | 2003010100:00:00 |
| 83 | 2004010100:00:00 |
| 84 | 2004123100:00:00 |
| 85 | 2006010200:00:00 |
| 86 | |
| 87 | # Test recur with no frequency |
| 88 | |
| 89 | *2013:1:0:20:10:11:12***2013010100:00:00*2013013012:00:00 |
| 90 | => |
| 91 | 2013012010:11:12 |
| 92 | |
| 93 | *2013:1:0:20:10:11:12***2013012100:00:00*2013013012:00:00 |
| 94 | => |
| 95 | |
| 96 | # Test overriding dates with no frequency |
| 97 | |
| 98 | *1990-1995:12:0:1:0:0:0 |
| 99 | => |
| 100 | 1990120100:00:00 |
| 101 | 1991120100:00:00 |
| 102 | 1992120100:00:00 |
| 103 | 1993120100:00:00 |
| 104 | 1994120100:00:00 |
| 105 | 1995120100:00:00 |
| 106 | |
| 107 | *1990-1995:12:0:1:0:0:0 |
| 108 | 1992-01-01 |
| 109 | 1994-12-31 |
| 110 | => |
| 111 | 1992120100:00:00 |
| 112 | 1993120100:00:00 |
| 113 | 1994120100:00:00 |
| 114 | |
| 115 | "; |
| 116 | |
| 117 | $::ti->tests(func => \&test, |
| 118 | tests => $tests); |
| 119 | $::ti->done_testing(); |
| 120 | |
| 121 | #Local Variables: |
| 122 | #mode: cperl |
| 123 | #indent-tabs-mode: nil |
| 124 | #cperl-indent-level: 3 |
| 125 | #cperl-continued-statement-offset: 2 |
| 126 | #cperl-continued-brace-offset: 0 |
| 127 | #cperl-brace-offset: 0 |
| 128 | #cperl-brace-imaginary-offset: 0 |
| 129 | #cperl-label-offset: 0 |
| 130 | #End: |