line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Calendar::Model::Day; |
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
Calendar::Model::Day - Simple class modelling Calendar day |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=cut |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1254
|
use Data::Dumper; |
|
1
|
|
|
|
|
11608
|
|
|
1
|
|
|
|
|
71
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
9
|
use DateTime; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
423
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $cal = Calendar::Model->new(selected_date=>DateTime->new(day=>3, month=>1, year=>2013)); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $day2 = $cal->weeks->[0][2]; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$day2->dow_name; # 'Tuesday' |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$day2->day_of_week; # 3 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$day2->dd; # '01' |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$day2->yyyy; # '2013' |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$day->to_DateTime; # DateTime object |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=over 4 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item dmy - date in DD-MM-YYYY format |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=item day_of_week - day of week (1 (Monday) to 7) |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item dow_name - day of week name (Monday, etc) |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item dd - day of month |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item mm - Month number ( 0-12 ) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item yyyy - Year (4 digits) |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=back |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has 'dmy' => ( |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => 'Str', |
55
|
|
|
|
|
|
|
required => 1, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
has 'dd' => ( |
60
|
|
|
|
|
|
|
is => 'ro', |
61
|
|
|
|
|
|
|
isa => 'Int', |
62
|
|
|
|
|
|
|
init_arg => undef, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has 'mm' => ( |
66
|
|
|
|
|
|
|
is => 'ro', |
67
|
|
|
|
|
|
|
isa => 'Int', |
68
|
|
|
|
|
|
|
init_arg => undef, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has 'yyyy' => ( |
72
|
|
|
|
|
|
|
is => 'ro', |
73
|
|
|
|
|
|
|
isa => 'Int', |
74
|
|
|
|
|
|
|
init_arg => undef, |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
has 'day_of_week' => ( |
79
|
|
|
|
|
|
|
is => 'ro', |
80
|
|
|
|
|
|
|
isa => 'Int', |
81
|
|
|
|
|
|
|
required => 1, |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
has 'dow_name' => ( |
85
|
|
|
|
|
|
|
is => 'ro', |
86
|
|
|
|
|
|
|
isa => 'Str', |
87
|
|
|
|
|
|
|
required => 1, |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
has 'is_selected_month' => ( |
91
|
|
|
|
|
|
|
is => 'ro', |
92
|
|
|
|
|
|
|
isa => 'Bool', |
93
|
|
|
|
|
|
|
); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 METHODS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 new |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Class constructor method, returns a Calendar::Model::Day object based on the arguments : |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=over 4 |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item dmy - required a date in DD-MM-YYYY format |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item day_of_week - required day of week (1 to 7) |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 BUILD |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Std Moose initialisation hook called by constructor method |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub BUILD { |
116
|
|
|
|
|
|
|
my $self = shift; |
117
|
|
|
|
|
|
|
my $args = shift; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# split dmy into dd mm yyyy, |
120
|
|
|
|
|
|
|
@{$self}{qw/dd mm yyyy/} = split(/\-/,$self->dmy); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# check if provided selected month and set flag appropriately |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# do working day check |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
# work out ordinal value/format |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head2 to_DateTime |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Object method, returns a DateTime object built from the days attributes |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub to_DateTime { |
136
|
|
|
|
|
|
|
my $self = shift; |
137
|
|
|
|
|
|
|
return DateTime->new(year => $self->yyyy, month => $self->mm, day => $self->dd); |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Copyright 2012 Aaron Trevena. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
145
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
146
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
See L<http://dev.perl.org/licenses/> for more information. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
1; |