line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Date::Remind::Event; |
2
|
1
|
|
|
1
|
|
816
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
36
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
4
|
1
|
|
|
1
|
|
16
|
use Carp qw/croak/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
65
|
|
5
|
1
|
|
|
1
|
|
5901
|
use DateTime; |
|
1
|
|
|
|
|
324168
|
|
|
1
|
|
|
|
|
56
|
|
6
|
1
|
|
|
1
|
|
12
|
use DateTime::Duration; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
1
|
|
|
1
|
|
7
|
use POSIX qw/floor/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
use constant { |
9
|
1
|
|
|
|
|
526
|
MINUTES_PER_HOUR => 60, |
10
|
1
|
|
|
1
|
|
94
|
}; |
|
1
|
|
|
|
|
2
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
13
|
|
|
|
|
|
|
our $ERROR = ''; |
14
|
|
|
|
|
|
|
our $BFLAG = 0; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
4
|
|
|
4
|
1
|
9656
|
my $proto = shift; |
19
|
4
|
|
33
|
|
|
21
|
my $text = shift || croak 'usage: new($text)'; |
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
|
|
44
|
my ( $date, $special, $tag, $duration, $time, $body ) |
22
|
|
|
|
|
|
|
= split(/ /, $text, 6); |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
|
|
19
|
my ( $y, $mon, $d ) = split( /\//, $date ); |
25
|
|
|
|
|
|
|
|
26
|
4
|
100
|
|
|
|
73
|
my $dt = DateTime->new( |
|
|
100
|
|
|
|
|
|
27
|
|
|
|
|
|
|
year => $y, |
28
|
|
|
|
|
|
|
month => $mon, |
29
|
|
|
|
|
|
|
day => $d, |
30
|
|
|
|
|
|
|
hour => $time eq '*' ? 0 : floor( $time / MINUTES_PER_HOUR ), |
31
|
|
|
|
|
|
|
minute => $time eq '*' ? 0 : $time % MINUTES_PER_HOUR, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
1180
|
my $dtduration; |
35
|
|
|
|
|
|
|
|
36
|
4
|
100
|
|
|
|
15
|
if ( $duration eq '*' ) { |
37
|
1
|
|
|
|
|
7
|
my $end = $dt->clone; |
38
|
1
|
|
|
|
|
17
|
$end->add( days => 1 ); |
39
|
1
|
|
|
|
|
919
|
$end->truncate( to => 'day' ); |
40
|
1
|
|
|
|
|
497
|
$dtduration = $end - $dt; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
3
|
|
|
|
|
20
|
$dtduration = DateTime::Duration->new( |
44
|
|
|
|
|
|
|
minutes => $duration, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Depending on what value of -b remind is called with, the body |
48
|
|
|
|
|
|
|
# is prefixed with human-readable duration text. Lets remove |
49
|
|
|
|
|
|
|
# (only) that text if it is there. |
50
|
3
|
100
|
|
|
|
230
|
if ( $BFLAG != 2 ) { |
51
|
2
|
|
|
|
|
15
|
$body =~ s/^.*? //; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
4
|
|
|
|
|
2986
|
my $self = { |
56
|
|
|
|
|
|
|
dt => $dt, |
57
|
|
|
|
|
|
|
tag => $tag, |
58
|
|
|
|
|
|
|
body => $body, |
59
|
|
|
|
|
|
|
duration => $dtduration, |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
4
|
|
33
|
|
|
31
|
my $class = ref($proto) || $proto; |
63
|
4
|
|
|
|
|
17
|
bless( $self, $class); |
64
|
4
|
|
|
|
|
17
|
return $self; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
1
|
858
|
sub date { shift->{dt} }; |
68
|
0
|
|
|
0
|
1
|
0
|
sub tag { shift->{tag} }; |
69
|
3
|
|
|
3
|
1
|
44
|
sub body { shift->{body} }; |
70
|
2
|
|
|
2
|
1
|
3966
|
sub duration { shift->{duration} }; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub end { |
73
|
2
|
|
|
2
|
1
|
2316
|
my $self = shift; |
74
|
2
|
|
|
|
|
17
|
return $self->{dt}->clone->add( $self->{duration} ); |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |