line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OurCal::Day; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
461
|
use OurCal::Event; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
805
|
use Lingua::EN::Numbers::Ordinate; |
|
1
|
|
|
|
|
381
|
|
|
1
|
|
|
|
|
58
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw(OurCal::Span); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
406
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
OurCal::Day - a representation of a day in OurCal |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $day = OurCal::Day->new( date => "2007-11-12"); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 day_of_week |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
What day of the week it is (Monday is 1, Sunday is 7) |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub day_of_week { |
31
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
32
|
0
|
|
|
|
|
|
return $self->{_dt}->strftime("%u"); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head2 day_of_month |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
What day of the month it is |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub day_of_month { |
42
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
return $self->{_dt}->strftime("%d"); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 is_first_day_of_month |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
IS this the first day of the month |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub is_first_day_of_month { |
53
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
# TODO did I do this for a clever reason or can I not just check |
55
|
|
|
|
|
|
|
# that day_of_month == 1 |
56
|
0
|
|
|
|
|
|
return $self->{_dt}->month != |
57
|
|
|
|
|
|
|
$self->{_dt}->clone->subtract( days => 1)->month; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 is_last_day_of_month |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Is this the last day of the month. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub is_last_day_of_month { |
67
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
return $self->{_dt}->month != |
69
|
|
|
|
|
|
|
$self->{_dt}->clone->add( days => 1)->month; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 is_this_span |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Calls C |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub is_this_span { |
79
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
return $self->is_today; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 is_today |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns whether or not this is today in the real world. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub is_today { |
90
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
91
|
0
|
|
|
|
|
|
my $now = DateTime->now->truncate( to => 'day' ); |
92
|
0
|
|
|
|
|
|
return $now == $self->{_dt}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 month |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Returns the month object this belongs to. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub month { |
102
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
103
|
0
|
|
|
|
|
|
my $date = $self->{_dt}->clone->truncate( to => 'month')->strftime("%Y-%m"); |
104
|
0
|
|
|
|
|
|
return $self->_span("OurCal::Month", $date); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 has_events |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Returns whether this day has events. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub has_events { |
114
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
115
|
0
|
|
|
|
|
|
my $cal = $self->calendar; |
116
|
0
|
|
|
|
|
|
return $cal->has_events( date => $self->date ); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 events |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the events for this day. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub events { |
126
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
127
|
0
|
|
|
|
|
|
my $cal = $self->calendar; |
128
|
0
|
|
|
|
|
|
return $cal->events( date => $self->date ); |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 as_string |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Returns this day as a string |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub as_string { |
139
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
140
|
0
|
|
|
|
|
|
my $day = ordinate($self->{_dt}->day()); |
141
|
0
|
|
|
|
|
|
return $self->{_dt}->strftime("%d/%m"); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 as_long_string |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Returns the day as a long, wordy, almost, dare I say it, verbose string. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub as_long_string { |
152
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
153
|
0
|
|
|
|
|
|
my $day = ordinate($self->{_dt}->day()); |
154
|
0
|
|
|
|
|
|
return $self->{_dt}->strftime("%A the $day of %B, %Y"); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 prev |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Returns the previous day. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub prev { |
164
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
165
|
0
|
|
|
|
|
|
return $self->_shift($self->{_dt}->clone->subtract( days => 1 )->strftime("%Y-%m-%d")); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 next |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Returns the next day |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub next { |
175
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
176
|
0
|
|
|
|
|
|
return $self->_shift($self->{_dt}->clone->add( days => 1 )->strftime("%Y-%m-%d")); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
1; |