line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Time::Moment::Ext; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1318
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
46
|
|
5
|
2
|
|
|
2
|
|
1077
|
use Time::Piece; |
|
2
|
|
|
|
|
19716
|
|
|
2
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
149
|
use parent 'Time::Moment'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $SQL_FORMAT = '%Y-%m-%d %H:%M:%S'; |
12
|
|
|
|
|
|
|
my $SQL_DATE = '%Y-%m-%d'; |
13
|
|
|
|
|
|
|
my $SQL_TIME = '%H:%M:%S'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub Time::Moment::strptime { |
16
|
2
|
|
|
2
|
0
|
5
|
my ($class, $str, $format) = @_; |
17
|
2
|
50
|
33
|
|
|
10
|
return unless ($str && $format); |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
5
|
return $class->from_object(scalar localtime->strptime($str, $format)); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub Time::Moment::from_datetime { |
23
|
2
|
|
|
2
|
0
|
493
|
my ($class, $str) = @_; |
24
|
2
|
50
|
|
|
|
7
|
return unless $str; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
9
|
return $class->strptime($str, $SQL_FORMAT); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub Time::Moment::to_datetime { |
30
|
1
|
|
|
1
|
0
|
327
|
return shift->strftime($SQL_FORMAT); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub Time::Moment::to_date { |
34
|
1
|
|
|
1
|
0
|
287
|
return shift->strftime($SQL_DATE); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub Time::Moment::to_time { |
38
|
1
|
|
|
1
|
0
|
8
|
return shift->strftime($SQL_TIME); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub Time::Moment::day { |
42
|
2
|
|
|
2
|
1
|
1286
|
return shift->day_of_month; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |