| 1 | package OurCal::Day; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use OurCal::Event; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use Lingua::EN::Numbers::Ordinate; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 2 | ▶ | use base qw(OurCal::Span); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 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 | 0 | ▶ | sub day_of_week { |
|
Subroutine
day_of_week: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 31 | 0 | 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 | 0 | ▶ | sub day_of_month { |
|
Subroutine
day_of_month: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 42 | 0 | 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 | 0 | ▶ | sub is_first_day_of_month { |
|
Subroutine
is_first_day_of_month: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 53 | 0 | 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 | return $self->{_dt}->month != | ||
| 57 | 0 | $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 | 0 | ▶ | sub is_last_day_of_month { |
|
Subroutine
is_last_day_of_month: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 67 | 0 | my $self = shift; | |
| 68 | return $self->{_dt}->month != | ||
| 69 | 0 | $self->{_dt}->clone->add( days => 1)->month; | |
| 70 | } | ||
| 71 | |||
| 72 | =head2 is_this_span | ||
| 73 | |||
| 74 | Calls C<is_today> | ||
| 75 | |||
| 76 | =cut | ||
| 77 | |||
| 78 | 0 | ▶ | sub is_this_span { |
|
Subroutine
is_this_span: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 79 | 0 | 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 | 0 | ▶ | sub is_today { |
|
Subroutine
is_today: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 90 | 0 | 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 | 0 | ▶ | sub month { |
|
Subroutine
month: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 102 | 0 | 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 | 0 | ▶ | sub has_events { |
|
Subroutine
has_events: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 114 | 0 | 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 | 0 | ▶ | sub events { |
|
Subroutine
events: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 126 | 0 | 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 | 0 | ▶ | sub as_string { |
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 139 | 0 | 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 | 0 | ▶ | sub as_long_string { |
|
Subroutine
as_long_string: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 152 | 0 | 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 | 0 | ▶ | sub prev { |
|
Subroutine
prev: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 164 | 0 | 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 | 0 | ▶ | sub next { |
|
Subroutine
next: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 175 | 0 | my $self = shift; | |
| 176 | 0 | return $self->_shift($self->{_dt}->clone->add( days => 1 )->strftime("%Y-%m-%d")); | |
| 177 | } | ||
| 178 | |||
| 179 | 2 | 1; | |