| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
############################################################################### |
|
3
|
|
|
|
|
|
|
## ## |
|
4
|
|
|
|
|
|
|
## Copyright (c) 2000 - 2015 by Steffen Beyer. ## |
|
5
|
|
|
|
|
|
|
## All rights reserved. ## |
|
6
|
|
|
|
|
|
|
## ## |
|
7
|
|
|
|
|
|
|
## This package is free software; you can redistribute it ## |
|
8
|
|
|
|
|
|
|
## and/or modify it under the same terms as Perl itself. ## |
|
9
|
|
|
|
|
|
|
## ## |
|
10
|
|
|
|
|
|
|
############################################################################### |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Date::Calendar; |
|
13
|
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
4070
|
BEGIN { eval { require bytes; }; } |
|
|
4
|
|
|
|
|
127
|
|
|
15
|
4
|
|
|
4
|
|
87
|
use strict; |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
153
|
|
|
16
|
4
|
|
|
4
|
|
15
|
use vars qw( @ISA @EXPORT @EXPORT_OK $VERSION ); |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
425
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
require Exporter; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
@EXPORT = qw(); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$VERSION = '6.4'; |
|
27
|
|
|
|
|
|
|
|
|
28
|
4
|
|
|
4
|
|
441
|
use Carp::Clan qw(^Date::); |
|
|
4
|
|
|
|
|
1307
|
|
|
|
4
|
|
|
|
|
31
|
|
|
29
|
4
|
|
|
4
|
|
2200
|
use Date::Calc::Object qw(:ALL); |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
2104
|
|
|
30
|
4
|
|
|
4
|
|
1954
|
use Date::Calendar::Year qw( check_year empty_period ); |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
4709
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new |
|
33
|
|
|
|
|
|
|
{ |
|
34
|
177
|
|
|
177
|
0
|
13455
|
my($class) = shift; |
|
35
|
177
|
|
|
|
|
264
|
my($profile) = shift; |
|
36
|
177
|
|
100
|
|
|
688
|
my($language) = shift || 0; |
|
37
|
177
|
|
|
|
|
226
|
my($self); |
|
38
|
|
|
|
|
|
|
|
|
39
|
177
|
|
|
|
|
267
|
$self = [ ]; |
|
40
|
177
|
|
50
|
|
|
725
|
$class = ref($class) || $class || 'Date::Calendar'; |
|
41
|
177
|
|
|
|
|
372
|
bless($self, $class); |
|
42
|
177
|
|
|
|
|
376
|
$self->[0] = { }; |
|
43
|
177
|
|
|
|
|
238
|
$self->[1] = $profile; |
|
44
|
177
|
|
|
|
|
204
|
$self->[2] = $language; |
|
45
|
177
|
|
|
|
|
270
|
$self->[3] = [@_]; |
|
46
|
177
|
|
|
|
|
398
|
return $self; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub year |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
227
|
|
|
227
|
0
|
911
|
my($self) = shift; |
|
52
|
227
|
|
|
|
|
823
|
my($year) = shift_year(\@_); |
|
53
|
|
|
|
|
|
|
|
|
54
|
227
|
|
|
|
|
832
|
&check_year($year); |
|
55
|
227
|
100
|
|
|
|
603
|
if (defined $self->[0]{$year}) |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
43
|
|
|
|
|
227
|
return $self->[0]{$year}; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
else |
|
60
|
|
|
|
|
|
|
{ |
|
61
|
184
|
|
|
|
|
586
|
return $self->[0]{$year} = |
|
62
|
184
|
|
|
|
|
281
|
Date::Calendar::Year->new( $year, $self->[1], $self->[2], @{$self->[3]} ); |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub cache_keys |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
2
|
|
|
2
|
0
|
10
|
my($self) = shift; |
|
69
|
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
3
|
return( sort {$a<=>$b} keys(%{$self->[0]}) ); |
|
|
13
|
|
|
|
|
21
|
|
|
|
2
|
|
|
|
|
15
|
|
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub cache_vals |
|
74
|
|
|
|
|
|
|
{ |
|
75
|
0
|
|
|
0
|
0
|
0
|
my($self) = shift; |
|
76
|
0
|
|
|
|
|
0
|
local($_); |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
0
|
return( map $self->[0]{$_}, sort {$a<=>$b} keys(%{$self->[0]}) ); |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub cache_clr |
|
82
|
|
|
|
|
|
|
{ |
|
83
|
0
|
|
|
0
|
0
|
0
|
my($self) = shift; |
|
84
|
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
$self->[0] = { }; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub cache_add |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
1
|
|
|
1
|
0
|
6
|
my($self) = shift; |
|
91
|
1
|
|
|
|
|
2
|
my($year); |
|
92
|
|
|
|
|
|
|
|
|
93
|
1
|
|
|
|
|
7
|
while (@_) |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
5
|
|
|
|
|
25
|
$year = shift_year(\@_); |
|
96
|
5
|
|
|
|
|
17
|
$self->year($year); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub cache_del |
|
101
|
|
|
|
|
|
|
{ |
|
102
|
1
|
|
|
1
|
0
|
21
|
my($self) = shift; |
|
103
|
1
|
|
|
|
|
2
|
my($year); |
|
104
|
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
6
|
while (@_) |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
1
|
|
|
|
|
7
|
$year = shift_year(\@_); |
|
108
|
1
|
50
|
|
|
|
7
|
if (exists $self->[0]{$year}) |
|
109
|
|
|
|
|
|
|
{ |
|
110
|
1
|
|
|
|
|
55
|
delete $self->[0]{$year}; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub date2index |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
0
|
|
|
0
|
0
|
0
|
my($self) = shift; |
|
118
|
0
|
|
|
|
|
0
|
my(@date) = shift_date(\@_); |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
0
|
return $self->year($date[0])->date2index(@date); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub labels |
|
124
|
|
|
|
|
|
|
{ |
|
125
|
5
|
|
|
5
|
0
|
13
|
my($self) = shift; |
|
126
|
5
|
|
|
|
|
5
|
my($year); |
|
127
|
|
|
|
|
|
|
my(@date); |
|
128
|
0
|
|
|
|
|
0
|
my(%result); |
|
129
|
|
|
|
|
|
|
|
|
130
|
5
|
50
|
|
|
|
9
|
if (@_) |
|
131
|
|
|
|
|
|
|
{ |
|
132
|
5
|
|
|
|
|
18
|
@date = shift_date(\@_); |
|
133
|
5
|
|
|
|
|
14
|
return $self->year($date[0])->labels(@date); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
else |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
0
|
|
|
|
|
0
|
local($_); |
|
138
|
0
|
|
|
|
|
0
|
%result = (); |
|
139
|
0
|
|
|
|
|
0
|
foreach $year (keys(%{$self->[0]})) |
|
|
0
|
|
|
|
|
0
|
|
|
140
|
|
|
|
|
|
|
{ |
|
141
|
0
|
|
|
|
|
0
|
grep( $result{$_} = 0, $self->year($year)->labels() ); |
|
142
|
|
|
|
|
|
|
} |
|
143
|
0
|
0
|
|
|
|
0
|
return wantarray ? (keys %result) : scalar(keys %result); |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub search |
|
148
|
|
|
|
|
|
|
{ |
|
149
|
1
|
|
|
1
|
0
|
13
|
my($self,$pattern) = @_; |
|
150
|
1
|
|
|
|
|
1
|
my($year); |
|
151
|
|
|
|
|
|
|
my(@result); |
|
152
|
|
|
|
|
|
|
|
|
153
|
1
|
|
|
|
|
2
|
@result = (); |
|
154
|
1
|
|
|
|
|
1
|
foreach $year (sort {$a<=>$b} keys(%{$self->[0]})) |
|
|
5
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
3
|
|
|
155
|
|
|
|
|
|
|
{ |
|
156
|
4
|
|
|
|
|
13
|
push( @result, $self->year($year)->search($pattern) ); |
|
157
|
|
|
|
|
|
|
} |
|
158
|
1
|
50
|
|
|
|
9
|
return wantarray ? (@result) : scalar(@result); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub tags |
|
162
|
|
|
|
|
|
|
{ |
|
163
|
0
|
|
|
0
|
0
|
0
|
my($self) = shift; |
|
164
|
0
|
|
|
|
|
0
|
my(%result) = (); |
|
165
|
0
|
|
|
|
|
0
|
my(@date); |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
0
|
if (@_) |
|
168
|
|
|
|
|
|
|
{ |
|
169
|
0
|
|
|
|
|
0
|
@date = shift_date(\@_); |
|
170
|
0
|
|
|
|
|
0
|
return $self->year($date[0])->tags(@date); |
|
171
|
|
|
|
|
|
|
} |
|
172
|
0
|
|
|
|
|
0
|
else { return \%result; } |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub delta_workdays |
|
176
|
|
|
|
|
|
|
{ |
|
177
|
10
|
|
|
10
|
0
|
180
|
my($self) = shift; |
|
178
|
10
|
|
|
|
|
38
|
my($yy1,$mm1,$dd1) = shift_date(\@_); |
|
179
|
10
|
|
|
|
|
33
|
my($yy2,$mm2,$dd2) = shift_date(\@_); |
|
180
|
10
|
|
|
|
|
19
|
my($including1,$including2) = (shift,shift); |
|
181
|
10
|
|
|
|
|
15
|
my($days,$empty,$year); |
|
182
|
|
|
|
|
|
|
|
|
183
|
10
|
|
|
|
|
12
|
$days = 0; |
|
184
|
10
|
|
|
|
|
11
|
$empty = 1; |
|
185
|
10
|
50
|
|
|
|
29
|
if ($yy1 == $yy2) |
|
|
|
100
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
{ |
|
187
|
0
|
|
|
|
|
0
|
return $self->year($yy1)->delta_workdays( |
|
188
|
|
|
|
|
|
|
$yy1,$mm1,$dd1, $yy2,$mm2,$dd2, $including1,$including2); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
elsif ($yy1 < $yy2) |
|
191
|
|
|
|
|
|
|
{ |
|
192
|
2
|
50
|
33
|
|
|
20
|
unless (($mm1 == 12) && ($dd1 == 31) && (!$including1)) |
|
|
|
|
33
|
|
|
|
|
|
193
|
|
|
|
|
|
|
{ |
|
194
|
2
|
|
|
|
|
11
|
$days += $self->year($yy1)->delta_workdays( |
|
195
|
|
|
|
|
|
|
$yy1,$mm1,$dd1, $yy1,12,31, $including1,1); |
|
196
|
2
|
|
|
|
|
5
|
$empty = 0; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
2
|
50
|
33
|
|
|
17
|
unless (($mm2 == 1) && ($dd2 == 1) && (!$including2)) |
|
|
|
|
33
|
|
|
|
|
|
199
|
|
|
|
|
|
|
{ |
|
200
|
2
|
|
|
|
|
8
|
$days += $self->year($yy2)->delta_workdays( |
|
201
|
|
|
|
|
|
|
$yy2, 1, 1, $yy2,$mm2,$dd2, 1,$including2); |
|
202
|
2
|
|
|
|
|
10
|
$empty = 0; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
2
|
|
|
|
|
16
|
for ( $year = $yy1 + 1; $year < $yy2; $year++ ) |
|
205
|
|
|
|
|
|
|
{ |
|
206
|
0
|
|
|
|
|
0
|
$days += $self->year($year)->delta_workdays( |
|
207
|
|
|
|
|
|
|
$year,1,1, $year,12,31, 1,1); |
|
208
|
0
|
|
|
|
|
0
|
$empty = 0; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
else |
|
212
|
|
|
|
|
|
|
{ |
|
213
|
8
|
50
|
33
|
|
|
50
|
unless (($mm2 == 12) && ($dd2 == 31) && (!$including2)) |
|
|
|
|
33
|
|
|
|
|
|
214
|
|
|
|
|
|
|
{ |
|
215
|
8
|
|
|
|
|
30
|
$days -= $self->year($yy2)->delta_workdays( |
|
216
|
|
|
|
|
|
|
$yy2,$mm2,$dd2, $yy2,12,31, $including2,1); |
|
217
|
8
|
|
|
|
|
13
|
$empty = 0; |
|
218
|
|
|
|
|
|
|
} |
|
219
|
8
|
50
|
33
|
|
|
50
|
unless (($mm1 == 1) && ($dd1 == 1) && (!$including1)) |
|
|
|
|
33
|
|
|
|
|
|
220
|
|
|
|
|
|
|
{ |
|
221
|
8
|
|
|
|
|
24
|
$days -= $self->year($yy1)->delta_workdays( |
|
222
|
|
|
|
|
|
|
$yy1, 1, 1, $yy1,$mm1,$dd1, 1,$including1); |
|
223
|
8
|
|
|
|
|
17
|
$empty = 0; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
8
|
|
|
|
|
26
|
for ( $year = $yy2 + 1; $year < $yy1; $year++ ) |
|
226
|
|
|
|
|
|
|
{ |
|
227
|
0
|
|
|
|
|
0
|
$days -= $self->year($year)->delta_workdays( |
|
228
|
|
|
|
|
|
|
$year,1,1, $year,12,31, 1,1); |
|
229
|
0
|
|
|
|
|
0
|
$empty = 0; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
} |
|
232
|
10
|
50
|
|
|
|
23
|
&empty_period() if ($empty); |
|
233
|
10
|
|
|
|
|
35
|
return $days; |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub add_delta_workdays |
|
237
|
|
|
|
|
|
|
{ |
|
238
|
7
|
|
|
7
|
0
|
112
|
my($self) = shift; |
|
239
|
7
|
|
|
|
|
28
|
my($yy,$mm,$dd) = shift_date(\@_); |
|
240
|
7
|
|
|
|
|
16
|
my($days) = shift; |
|
241
|
7
|
|
|
|
|
9
|
my($date,$rest,$sign); |
|
242
|
|
|
|
|
|
|
|
|
243
|
7
|
50
|
|
|
|
16
|
if ($days == 0) |
|
244
|
|
|
|
|
|
|
{ |
|
245
|
0
|
|
|
|
|
0
|
$rest = $self->year($yy)->date2index($yy,$mm,$dd); # check date |
|
246
|
0
|
|
|
|
|
0
|
$date = Date::Calc->new($yy,$mm,$dd); |
|
247
|
0
|
0
|
|
|
|
0
|
return wantarray ? ($date,$days) : $date; |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
else |
|
250
|
|
|
|
|
|
|
{ |
|
251
|
7
|
100
|
|
|
|
19
|
$sign = ($days > 0) ? +1 : -1; |
|
252
|
7
|
|
|
|
|
22
|
($date,$rest,$sign) = $self->year($yy)->add_delta_workdays($yy,$mm,$dd,$days,$sign); |
|
253
|
7
|
|
|
|
|
20
|
while ($sign) |
|
254
|
|
|
|
|
|
|
{ |
|
255
|
7
|
|
|
|
|
21
|
($date,$rest,$sign) = $self->year($date)->add_delta_workdays($date,$rest,$sign); |
|
256
|
|
|
|
|
|
|
} |
|
257
|
7
|
100
|
|
|
|
118
|
return wantarray ? ($date,$rest) : $date; |
|
258
|
|
|
|
|
|
|
} |
|
259
|
|
|
|
|
|
|
} |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
sub is_full |
|
262
|
|
|
|
|
|
|
{ |
|
263
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
|
264
|
0
|
|
|
|
|
|
my(@date) = shift_date(\@_); |
|
265
|
0
|
|
|
|
|
|
my($year) = $self->year($date[0]); |
|
266
|
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
|
return $year->vec_full->bit_test( $year->date2index(@date) ); |
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub is_half |
|
271
|
|
|
|
|
|
|
{ |
|
272
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
|
273
|
0
|
|
|
|
|
|
my(@date) = shift_date(\@_); |
|
274
|
0
|
|
|
|
|
|
my($year) = $self->year($date[0]); |
|
275
|
|
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
|
return $year->vec_half->bit_test( $year->date2index(@date) ); |
|
277
|
|
|
|
|
|
|
} |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
sub is_work |
|
280
|
|
|
|
|
|
|
{ |
|
281
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
|
282
|
0
|
|
|
|
|
|
my(@date) = shift_date(\@_); |
|
283
|
0
|
|
|
|
|
|
my($year) = $self->year($date[0]); |
|
284
|
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
return $year->vec_work->bit_test( $year->date2index(@date) ); |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
1; |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
__END__ |