| 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 | our $obj = new Date::Manip::Date; |
| 10 | $obj->config("forcedate","2000-01-21-12:00:00,America/New_York"); |
| 11 | $obj->config("defaulttime","curr"); |
| 12 | |
| 13 | sub test { |
| 14 | my(@test)=@_; |
| 15 | if ($test[0] eq "config") { |
| 16 | shift(@test); |
| 17 | $obj->config(@test); |
| 18 | return (); |
| 19 | } |
| 20 | |
| 21 | $obj->_init(); |
| 22 | my $err = $obj->parse_date(@test); |
| 23 | if ($err) { |
| 24 | return $obj->err(); |
| 25 | } else { |
| 26 | my $d1 = $obj->value(); |
| 27 | my $d2 = $obj->value("gmt"); |
| 28 | return($d1,$d2); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | my $tests=" |
| 33 | |
| 34 | Friday => 2000012100:00:00 2000012105:00:00 |
| 35 | |
| 36 | Monday => 2000011700:00:00 2000011705:00:00 |
| 37 | |
| 38 | Saturday => 2000012200:00:00 2000012205:00:00 |
| 39 | |
| 40 | 'next year' => 2001012100:00:00 2001012105:00:00 |
| 41 | |
| 42 | 'last year' => 1999012100:00:00 1999012105:00:00 |
| 43 | |
| 44 | 'next month' => 2000022100:00:00 2000022105:00:00 |
| 45 | |
| 46 | 'last month' => 1999122100:00:00 1999122105:00:00 |
| 47 | |
| 48 | 'next week' => 2000012800:00:00 2000012805:00:00 |
| 49 | |
| 50 | 'last week' => 2000011400:00:00 2000011405:00:00 |
| 51 | |
| 52 | 'next friday' => 2000012800:00:00 2000012805:00:00 |
| 53 | |
| 54 | 'next sunday' => 2000012300:00:00 2000012305:00:00 |
| 55 | |
| 56 | 'last friday' => 2000011400:00:00 2000011405:00:00 |
| 57 | |
| 58 | 'last sunday' => 2000011600:00:00 2000011605:00:00 |
| 59 | |
| 60 | 'last tue in Jun 96' => 1996062500:00:00 1996062504:00:00 |
| 61 | |
| 62 | 'last tueSday of Jan' => 2000012500:00:00 2000012505:00:00 |
| 63 | |
| 64 | 'last day in October 1997' => 1997103100:00:00 1997103105:00:00 |
| 65 | |
| 66 | "; |
| 67 | |
| 68 | $::ti->tests(func => \&test, |
| 69 | tests => $tests); |
| 70 | $::ti->done_testing(); |
| 71 | |
| 72 | #Local Variables: |
| 73 | #mode: cperl |
| 74 | #indent-tabs-mode: nil |
| 75 | #cperl-indent-level: 3 |
| 76 | #cperl-continued-statement-offset: 2 |
| 77 | #cperl-continued-brace-offset: 0 |
| 78 | #cperl-brace-offset: 0 |
| 79 | #cperl-brace-imaginary-offset: 0 |
| 80 | #cperl-label-offset: 0 |
| 81 | #End: |