line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::InflateColumn::TimePiece; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Auto-create Time::Piece objects from integer (number of seconds since epoch) columns |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
376726
|
use v5.10; |
|
2
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
35
|
|
8
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
71
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.03'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
15
|
use parent 'DBIx::Class'; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
11
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
1657
|
use Time::Piece; |
|
2
|
|
|
|
|
12574
|
|
|
2
|
|
|
|
|
31
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub register_column { |
17
|
14
|
|
|
14
|
0
|
162869
|
my ($self, $column, $info, @rest) = @_; |
18
|
|
|
|
|
|
|
|
19
|
14
|
|
|
|
|
52
|
$self->next::method( $column, $info, @rest ); |
20
|
|
|
|
|
|
|
|
21
|
14
|
|
100
|
|
|
5533
|
my $data_type = $info->{data_type} || ''; |
22
|
14
|
|
100
|
|
|
53
|
my $is_integer = $data_type eq 'integer' || $data_type eq 'int'; |
23
|
|
|
|
|
|
|
|
24
|
14
|
100
|
100
|
|
|
62
|
return if !$info->{inflate_time_piece} || !$is_integer; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$self->inflate_column( |
27
|
|
|
|
|
|
|
$column => { |
28
|
|
|
|
|
|
|
inflate => sub { |
29
|
6
|
|
|
6
|
|
420683
|
my $dt = localtime shift; |
30
|
6
|
|
|
|
|
250
|
return $dt; |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
deflate => sub { |
33
|
6
|
|
|
6
|
|
423754
|
return shift->epoch; |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
} |
36
|
4
|
|
|
|
|
60
|
); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
__END__ |