line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mindcal; |
2
|
1
|
|
|
1
|
|
24061
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
1479
|
use DateTime; |
|
1
|
|
|
|
|
307571
|
|
|
1
|
|
|
|
|
235
|
|
5
|
1
|
|
|
1
|
|
7389
|
use Log::Log4perl qw(:easy); |
|
1
|
|
|
|
|
66177
|
|
|
1
|
|
|
|
|
9
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
########################################### |
10
|
|
|
|
|
|
|
sub new { |
11
|
|
|
|
|
|
|
########################################### |
12
|
1
|
|
|
1
|
0
|
392
|
my($class, %options) = @_; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
15
|
my $self = { |
15
|
|
|
|
|
|
|
month_items => [qw(0 3 3 6 1 4 6 2 5 0 3 5)], |
16
|
|
|
|
|
|
|
century_adjust => { |
17
|
|
|
|
|
|
|
qw(1700 4 1800 2 1900 0 2000 6 |
18
|
|
|
|
|
|
|
2100 4 2200 2 2300 0) |
19
|
|
|
|
|
|
|
}, |
20
|
|
|
|
|
|
|
dows => [qw[Sunday Monday Tuesday Wednesday Thursday Friday Saturday]], |
21
|
|
|
|
|
|
|
%options, |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
|
24
|
1
|
50
|
33
|
|
|
12
|
if(!defined $self->{date} or |
25
|
|
|
|
|
|
|
ref($self->{date}) ne "DateTime") { |
26
|
0
|
|
|
|
|
0
|
LOGDIE "new() called without DateTime date"; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
2
|
bless $self, $class; |
30
|
1
|
|
|
|
|
4
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
########################################### |
34
|
|
|
|
|
|
|
sub month_item { |
35
|
|
|
|
|
|
|
########################################### |
36
|
2
|
|
|
2
|
0
|
3
|
my($self) = @_; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
12
|
return $self->{month_items}->[$self->{date}->month() - 1]; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
########################################### |
42
|
|
|
|
|
|
|
sub year_item { |
43
|
|
|
|
|
|
|
########################################### |
44
|
2
|
|
|
2
|
0
|
7
|
my($self) = @_; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
1
|
|
882
|
use integer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
10
|
|
47
|
2
|
|
|
|
|
14
|
my $year = $self->{date}->year(); |
48
|
2
|
|
|
|
|
26
|
my $year2 = ($year % 100); |
49
|
|
|
|
|
|
|
|
50
|
2
|
|
|
|
|
15
|
return (($year2 + ($year2 / 4)) % 7); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
########################################### |
54
|
|
|
|
|
|
|
sub century_adjust { |
55
|
|
|
|
|
|
|
########################################### |
56
|
2
|
|
|
2
|
0
|
3
|
my($self) = @_; |
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
1
|
|
93
|
use integer; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
8
|
my $year = $self->{date}->year(); |
61
|
2
|
|
|
|
|
16
|
my $month = $self->{date}->month(); |
62
|
2
|
|
|
|
|
10
|
my $cent = $year / 100; |
63
|
|
|
|
|
|
|
|
64
|
2
|
50
|
|
|
|
10
|
if(!exists $self->{century_adjust}->{ $cent * 100 }) { |
65
|
0
|
|
|
|
|
0
|
LOGDIE "Century $cent not supported (yet)."; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
2
|
|
|
|
|
7
|
return $self->{century_adjust}->{ $cent*100 }; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
########################################### |
72
|
|
|
|
|
|
|
sub day_item { |
73
|
|
|
|
|
|
|
########################################### |
74
|
2
|
|
|
2
|
0
|
355
|
my($self) = @_; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
10
|
return $self->{date}->day(); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
########################################### |
80
|
|
|
|
|
|
|
sub weekday { |
81
|
|
|
|
|
|
|
########################################### |
82
|
1
|
|
|
1
|
0
|
3
|
my($self) = @_; |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
4
|
my $dow = $self->year_item() + |
85
|
|
|
|
|
|
|
$self->month_item() + |
86
|
|
|
|
|
|
|
$self->day_item() + |
87
|
|
|
|
|
|
|
$self->adjust; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
6
|
return $self->{dows}->[ $dow % 7 ]; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
########################################### |
93
|
|
|
|
|
|
|
sub adjust { |
94
|
|
|
|
|
|
|
########################################### |
95
|
2
|
|
|
2
|
0
|
403
|
my($self) = @_; |
96
|
|
|
|
|
|
|
|
97
|
2
|
|
|
|
|
7
|
my $adj = $self->century_adjust(); |
98
|
2
|
|
|
|
|
7
|
my $month = $self->{date}->month(); |
99
|
|
|
|
|
|
|
|
100
|
2
|
50
|
33
|
|
|
14
|
$adj-- if $self->is_leap_year() and $month <= 2; |
101
|
|
|
|
|
|
|
|
102
|
2
|
|
|
|
|
7
|
return $adj; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
########################################### |
106
|
|
|
|
|
|
|
sub is_leap_year { |
107
|
|
|
|
|
|
|
########################################### |
108
|
2
|
|
|
2
|
0
|
3
|
my($self) = @_; |
109
|
|
|
|
|
|
|
|
110
|
2
|
|
|
|
|
8
|
my $year = $self->{date}->year(); |
111
|
|
|
|
|
|
|
|
112
|
2
|
50
|
|
|
|
12
|
return 0 if $year % 4; |
113
|
2
|
50
|
|
|
|
6
|
return 1 if $year % 100; |
114
|
2
|
50
|
|
|
|
5
|
return 0 if $year % 400; |
115
|
2
|
|
|
|
|
20
|
return 1; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
__END__ |