line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::TimelogTxt::Event; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
53385
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
4
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
35
|
|
5
|
2
|
|
|
2
|
|
6
|
use Time::Local; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
64
|
|
6
|
2
|
|
|
2
|
|
279
|
use App::TimelogTxt::Utils; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
713
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
11
|
|
|
|
|
|
|
{ |
12
|
2
|
|
|
2
|
1
|
551
|
my ($class, $task, $time) = @_; |
13
|
2
|
|
33
|
|
|
5
|
$time ||= time; |
14
|
2
|
|
|
|
|
8
|
my ( $proj ) = $task =~ m/\+(\S+)/; |
15
|
2
|
|
|
|
|
6
|
my $obj = { |
16
|
|
|
|
|
|
|
epoch => $time, task => $task, project => $proj |
17
|
|
|
|
|
|
|
}; |
18
|
2
|
|
|
|
|
7
|
return bless $obj, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new_from_line |
22
|
|
|
|
|
|
|
{ |
23
|
4
|
|
|
4
|
1
|
1301
|
my ($class, $line) = @_; |
24
|
4
|
100
|
|
|
|
14
|
die "Not a valid event line.\n" unless $line; |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
|
|
9
|
my ( $stamp, $time, $task ) = App::TimelogTxt::Utils::parse_event_line( $line ); |
27
|
2
|
|
|
|
|
6
|
my ( $proj ) = $task =~ m/\+(\S+)/; |
28
|
2
|
|
|
|
|
6
|
$stamp = App::TimelogTxt::Utils::canonical_datestamp( $stamp ); |
29
|
2
|
|
|
|
|
6
|
my $datetime = "$stamp $time"; |
30
|
2
|
|
|
|
|
7
|
my $obj = { |
31
|
|
|
|
|
|
|
stamp => $stamp, task => $task, project => $proj, _date_time => $datetime |
32
|
|
|
|
|
|
|
}; |
33
|
2
|
|
|
|
|
6
|
return bless $obj, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
8
|
1
|
38
|
sub task { return $_[0]->{task}; } |
37
|
4
|
|
|
4
|
1
|
19
|
sub project { return $_[0]->{project}; } |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub to_string |
40
|
|
|
|
|
|
|
{ |
41
|
4
|
|
|
4
|
1
|
5
|
my ($self) = @_; |
42
|
4
|
|
|
|
|
8
|
return $self->_date_time . ' ' . $self->task; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub epoch |
46
|
|
|
|
|
|
|
{ |
47
|
4
|
|
|
4
|
1
|
6
|
my ($self) = @_; |
48
|
4
|
100
|
|
|
|
11
|
if( !defined $self->{epoch} ) |
49
|
|
|
|
|
|
|
{ |
50
|
2
|
|
|
|
|
11
|
my @fields = split /[^0-9]/, $self->{_date_time}; |
51
|
2
|
|
|
|
|
5
|
$fields[0] -= 1900; |
52
|
2
|
|
|
|
|
2
|
$fields[1] -= 1; |
53
|
2
|
|
|
|
|
6
|
$self->{epoch} = timelocal( reverse @fields ); |
54
|
|
|
|
|
|
|
} |
55
|
4
|
|
|
|
|
101
|
return $self->{epoch}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _date_time { |
59
|
4
|
|
|
4
|
|
4
|
my ($self) = @_; |
60
|
4
|
100
|
|
|
|
10
|
if( !defined $self->{_date_time} ) |
61
|
|
|
|
|
|
|
{ |
62
|
2
|
|
|
|
|
36
|
$self->{_date_time} = App::TimelogTxt::Utils::fmt_time( $self->{epoch} ); |
63
|
|
|
|
|
|
|
} |
64
|
4
|
|
|
|
|
14
|
return $self->{_date_time}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub stamp |
68
|
|
|
|
|
|
|
{ |
69
|
4
|
|
|
4
|
1
|
1283
|
my ($self) = @_; |
70
|
4
|
|
66
|
|
|
24
|
$self->{stamp} ||= App::TimelogTxt::Utils::fmt_date( $self->{epoch} ); |
71
|
4
|
|
|
|
|
23
|
return $_[0]->{stamp}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub is_stop |
75
|
|
|
|
|
|
|
{ |
76
|
4
|
|
|
4
|
1
|
6
|
my ($self) = @_; |
77
|
4
|
|
|
|
|
13
|
return App::TimelogTxt::Utils::is_stop_cmd( $_[0]->{task} ); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
__END__ |