Debian Codegraph @

t/date.calc.date_delta_business.0.t

raw symbols SCIP
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 $obj1 = new Date::Manip::Date;
10 $obj1->config("forcedate","now,America/New_York");
11 our $obj2 = $obj1->new_delta();
12
13 sub test {
14 my(@test)=@_;
15
16 my $err = $obj1->parse(shift(@test));
17 return $$obj1{"err"} if ($err);
18 $err = $obj2->parse(shift(@test));
19 return $$obj2{"err"} if ($err);
20
21 my $obj3 = $obj1->calc($obj2,@test);
22 return if (! defined $obj3);
23 $err = $obj3->err();
24 return $err if ($err);
25 my $ret = $obj3->value();
26 return $ret;
27 }
28
29 my $tests="
30
31 'Wed Nov 20 1996 noon' 'business +0:5:0:0' => 1996112108:00:00
32
33 'Wed Nov 20 1996 noon' 'business -0:5:0:0' 1 => 1996112108:00:00
34
35 'Wed Nov 20 1996 noon' 'business +0:2:0:0' => 1996112014:00:00
36
37 'Wed Nov 20 1996 noon' 'business -0:2:0:0' 1 => 1996112014:00:00
38
39 'Wed Nov 20 1996 noon' 'business +3:2:0:0' => 1996112514:00:00
40
41 'Wed Nov 20 1996 noon' 'business 3:2:0:0' 1 => 1996111510:00:00
42
43 'Wed Nov 20 1996 noon' 'business -3:2:0:0' => 1996111510:00:00
44
45 'Wed Nov 20 1996 noon' 'business +3:7:0:0' => 1996112610:00:00
46
47 'Wed Nov 20 1996 noon' 'business +6:2:0:0' => 1996112814:00:00
48
49 'Dec 31 1996 noon' 'business +1:2:0:0' => 1997010114:00:00
50
51 'Dec 30 1996 noon' 'business +1:2:0:0' => 1996123114:00:00
52
53 'Mar 31 1997 16:59:59' 'business + 1 sec' => 1997040108:00:00
54
55 'Wed Nov 20 1996 noon' 'business +0:0:1:0:0:0:0' => 1996112712:00:00
56
57 2002120600:00:00 '- business 4 hours' => 2002120513:00:00
58
59 2002120600:00:01 '- business 4 hours' => 2002120513:00:00
60
61 2002120523:59:59 '- business 4 hours' => 2002120513:00:00
62
63 2002120602:00:00 '- business 4 hours' => 2002120513:00:00
64
65 2002120609:00:00 '- business 4 hours' => 2002120514:00:00
66
67 2002120609:00:10 '- business 4 hours' => 2002120514:00:10
68
69 2002120611:00:00 '- business 4 hours' => 2002120516:00:00
70
71 2002120612:00:00 '- business 4 hours' => 2002120608:00:00
72
73 2002120512:00:00 '+ business 4 hours' => 2002120516:00:00
74
75 2002120514:00:00 '+ business 4 hours' => 2002120609:00:00
76
77 2002120522:00:00 '+ business 4 hours' => 2002120612:00:00
78
79 2002120523:59:59 '+ business 4 hours' => 2002120612:00:00
80
81 2002120602:00:00 '+ business 4 hours' => 2002120612:00:00
82
83 2002120609:00:00 '+ business 4 hours' => 2002120613:00:00
84
85 1998010500:00:00 '0:1:1:0:0:0:0 business' 0 => 1998021208:00:00
86
87 1998010500:00:00 '0:1:1:0:0:0:0 business' 1 => 1997112808:00:00
88
89 1998010500:00:00 '0:1:1:0:0:0:0 business' 2 => '[calc] Unable to perform calculation'
90
91 1998010400:00:00 '0:1:1:0:0:0:0 business' 0 => 1998021108:00:00
92
93 1998010400:00:00 '0:1:1:0:0:0:0 business' 1 => 1997112708:00:00
94
95 1998010400:00:00 '0:1:1:0:0:0:0 business' 2 => '[calc] Unable to perform calculation'
96
97 ";
98
99 $::ti->tests(func => \&test,
100 tests => $tests);
101 $::ti->done_testing();
102
103 #Local Variables:
104 #mode: cperl
105 #indent-tabs-mode: nil
106 #cperl-indent-level: 3
107 #cperl-continued-statement-offset: 2
108 #cperl-continued-brace-offset: 0
109 #cperl-brace-offset: 0
110 #cperl-brace-imaginary-offset: 0
111 #cperl-label-offset: 0
112 #End: