line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Time::List::Rows::Row; |
2
|
7
|
|
|
7
|
|
96
|
use 5.008_001; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
232
|
|
3
|
7
|
|
|
7
|
|
27
|
use strict; |
|
7
|
|
|
|
|
6
|
|
|
7
|
|
|
|
|
173
|
|
4
|
7
|
|
|
7
|
|
25
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
165
|
|
5
|
7
|
|
|
7
|
|
28
|
use Time::Piece; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
33
|
|
6
|
7
|
|
|
7
|
|
353
|
use Class::Accessor::Lite; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
26
|
|
7
|
7
|
|
|
7
|
|
2468
|
use Time::List::Constant; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
34
|
|
8
|
7
|
|
|
7
|
|
3854
|
use Encode qw/decode_utf8/; |
|
7
|
|
|
|
|
56547
|
|
|
7
|
|
|
|
|
3848
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $unit_time = { |
13
|
|
|
|
|
|
|
DAY() => 3600 * 24 , |
14
|
|
|
|
|
|
|
WEEK() => 3600 * 24 * 7 , |
15
|
|
|
|
|
|
|
HOUR() => 3600 , |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %DEFAULTS = ( |
19
|
|
|
|
|
|
|
time_unit => DAY() , |
20
|
|
|
|
|
|
|
output_type => ARRAY() , |
21
|
|
|
|
|
|
|
limit_rows => 0 , |
22
|
|
|
|
|
|
|
input_strftime_form => '%Y-%m-%d %H:%M:%S', |
23
|
|
|
|
|
|
|
output_strftime_form => '%Y-%m-%d %H:%M:%S', |
24
|
|
|
|
|
|
|
show_end_time => 0 , |
25
|
|
|
|
|
|
|
end_time_separate_chars => '~' , |
26
|
|
|
|
|
|
|
unixtime => 0, |
27
|
|
|
|
|
|
|
datetime => 0, |
28
|
|
|
|
|
|
|
values => {}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Class::Accessor::Lite->mk_accessors(keys %DEFAULTS); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
34
|
33
|
|
|
33
|
1
|
33
|
my $class = shift; |
35
|
|
|
|
|
|
|
|
36
|
33
|
50
|
|
|
|
118
|
my %args = @_ == 1 ? %{ $_[0] } : @_; |
|
0
|
|
|
|
|
0
|
|
37
|
33
|
100
|
|
|
|
41
|
if($args{show_end_time}){ |
38
|
3
|
|
|
|
|
8
|
my ($unixtime) = split("\t",$args{unixtime}); |
39
|
3
|
|
|
|
|
6
|
$args{datetime} = localtime($unixtime)->strftime( '%Y-%m-%d %H:%M:%S'); |
40
|
|
|
|
|
|
|
}else{ |
41
|
30
|
|
|
|
|
54
|
$args{datetime} = localtime($args{unixtime})->strftime( '%Y-%m-%d %H:%M:%S'); |
42
|
|
|
|
|
|
|
} |
43
|
33
|
|
|
|
|
796
|
decode_utf8($args{datetime}); |
44
|
33
|
|
|
|
|
660
|
my $self = bless { |
45
|
|
|
|
|
|
|
%DEFAULTS, |
46
|
|
|
|
|
|
|
values => {}, |
47
|
|
|
|
|
|
|
%args, |
48
|
|
|
|
|
|
|
}, $class; |
49
|
33
|
|
|
|
|
142
|
$self; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub set{ |
53
|
39
|
|
|
39
|
0
|
39
|
my ($self , $values) = @_; |
54
|
39
|
|
|
|
|
63
|
$self->values( |
55
|
39
|
|
|
|
|
32
|
{%{$self->values},%$values} |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_hash_seed{ |
60
|
3
|
|
|
3
|
0
|
4
|
my ($self) = @_; |
61
|
3
|
|
|
|
|
5
|
my $values = $self->values; |
62
|
3
|
50
|
|
|
|
10
|
if($self->show_end_time){ |
63
|
0
|
|
|
|
|
0
|
join($self->end_time_separate_chars, |
64
|
0
|
|
|
|
|
0
|
map{decode_utf8(localtime($_)->strftime($self->output_strftime_form))}split("\t",$self->unixtime)) => $values; |
65
|
|
|
|
|
|
|
}else{ |
66
|
3
|
|
|
|
|
11
|
decode_utf8(localtime($self->unixtime)->strftime($self->output_strftime_form)) => $values; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub get_key{ |
71
|
153
|
|
|
153
|
0
|
153
|
my ($self) = @_; |
72
|
153
|
|
|
|
|
229
|
my $values = $self->values; |
73
|
|
|
|
|
|
|
|
74
|
153
|
100
|
|
|
|
505
|
if($self->show_end_time){ |
75
|
6
|
|
|
|
|
133
|
join($self->end_time_separate_chars, |
76
|
3
|
|
|
|
|
12
|
map{decode_utf8(localtime($_)->strftime($self->output_strftime_form))}split("\t",$self->unixtime)); |
77
|
|
|
|
|
|
|
}else{ |
78
|
150
|
|
|
|
|
582
|
decode_utf8(localtime($self->unixtime)->strftime($self->output_strftime_form)); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub get_values{ |
83
|
153
|
|
|
153
|
0
|
570
|
my ($self) = @_; |
84
|
153
|
|
|
|
|
270
|
my $values = $self->values; |
85
|
|
|
|
|
|
|
|
86
|
153
|
|
|
|
|
639
|
$values->{$_} = $self->$_ for qw/datetime unixtime/; |
87
|
153
|
|
|
|
|
1165
|
$values->{output_time} = $self->get_key; |
88
|
153
|
|
|
|
|
7063
|
return $values; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
__END__ |