File: date.list_holidays.4.t

package info (click to toggle)
libdate-manip-perl 6.83-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 16,264 kB
  • sloc: perl: 245,655; sh: 54; makefile: 11
file content (129 lines) | stat: -rwxr-xr-x 2,389 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/perl

use warnings;
use strict;
use Test::Inter;
$::ti = new Test::Inter $0;
require "tests.pl";

our $obj = new Date::Manip::Date;
$obj->config("forcedate","2000-01-01-00:00:00,America/New_York");

sub test {
   my(@test)=@_;

   if ($test[0] eq 'configfile') {
      $obj->config('EraseHolidays',1,
                   'ConfigFile',"$test[1]");
      return ();
   }

   my @ret = ();
   my($y0,$y1) = @test;
   foreach my $y ($y0..$y1) {
      my @date = $obj->list_holidays($y);
      foreach my $date (@date) {
         my $d = $date->value();
         push(@ret,$d);
      }
   }
   return @ret;
}

my $tests="

configfile New_Years.1.cnf =>

2000 2015 =>
   2000010100:00:00
   2001010100:00:00
   2002010100:00:00
   2003010100:00:00
   2004010100:00:00
   2005010100:00:00
   2006010100:00:00
   2007010100:00:00
   2008010100:00:00
   2009010100:00:00
   2010010100:00:00
   2011010100:00:00
   2012010100:00:00
   2013010100:00:00
   2014010100:00:00
   2015010100:00:00

configfile New_Years.2.cnf =>

2000 2015 =>
   2001010100:00:00
   2002010100:00:00
   2003010100:00:00
   2004010100:00:00
   2004123100:00:00
   2006010200:00:00
   2007010100:00:00
   2008010100:00:00
   2009010100:00:00
   2010010100:00:00
   2010123100:00:00
   2012010200:00:00
   2013010100:00:00
   2014010100:00:00
   2015010100:00:00

configfile New_Years.3.cnf =>

2000 2015 =>
   2000010100:00:00
   2001010100:00:00
   2002010100:00:00
   2003010100:00:00
   2004010100:00:00
   2005010100:00:00
   2006010200:00:00
   2007010100:00:00
   2008010100:00:00
   2009010100:00:00
   2010010100:00:00
   2011010100:00:00
   2012010200:00:00
   2013010100:00:00
   2014010100:00:00
   2015010100:00:00

configfile New_Years.4.cnf =>

2000 2015 =>
   2000010100:00:00
   2001010100:00:00
   2002010100:00:00
   2003010100:00:00
   2004010100:00:00
   2005010100:00:00
   2006010200:00:00
   2007010100:00:00
   2008010100:00:00
   2009010100:00:00
   2010010100:00:00
   2011010100:00:00
   2012010200:00:00
   2013010100:00:00
   2014010100:00:00
   2015010100:00:00

";

$::ti->tests(func  => \&test,
             tests => $tests);
$::ti->done_testing();

#Local Variables:
#mode: cperl
#indent-tabs-mode: nil
#cperl-indent-level: 3
#cperl-continued-statement-offset: 2
#cperl-continued-brace-offset: 0
#cperl-brace-offset: 0
#cperl-brace-imaginary-offset: 0
#cperl-label-offset: 0
#End: