line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Time::Format::MySQL; |
2
|
2
|
|
|
2
|
|
29928
|
use 5.008005; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
82
|
|
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
73
|
|
4
|
2
|
|
|
2
|
|
21
|
use warnings; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
75
|
|
5
|
2
|
|
|
2
|
|
11
|
use Carp qw(croak); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
145
|
|
6
|
2
|
|
|
2
|
|
2174
|
use Time::Piece (); |
|
2
|
|
|
|
|
33635
|
|
|
2
|
|
|
|
|
53
|
|
7
|
2
|
|
|
2
|
|
1531
|
use parent qw(Exporter); |
|
2
|
|
|
|
|
538
|
|
|
2
|
|
|
|
|
9
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(from_unixtime unix_timestamp); |
9
|
|
|
|
|
|
|
our $VERSION = "0.03"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $DEFAULT_FORMAT = '%Y-%m-%d %H:%M:%S'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub from_unixtime { |
14
|
3
|
100
|
|
3
|
1
|
5748
|
my $unixtime = shift or croak('Incorrect parameter count'); |
15
|
2
|
|
66
|
|
|
21
|
my $format = shift || $DEFAULT_FORMAT; |
16
|
2
|
|
|
|
|
11
|
Time::Piece::localtime($unixtime)->strftime($format); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub unix_timestamp { |
20
|
3
|
100
|
|
3
|
1
|
2447
|
my $datetime = shift or return time; |
21
|
2
|
|
66
|
|
|
12
|
my $format = shift || $DEFAULT_FORMAT; |
22
|
2
|
|
|
|
|
8
|
Time::Piece::localtime->strptime($datetime, $format)->epoch; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
__END__ |