line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Time::Moment::Ext; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1223
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
57
|
|
5
|
2
|
|
|
2
|
|
650
|
use Time::Piece (); |
|
2
|
|
|
|
|
14911
|
|
|
2
|
|
|
|
|
59
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
14
|
use parent 'Time::Moment'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
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
|
3
|
my ($class, $str, $format) = @_; |
17
|
2
|
50
|
33
|
|
|
10
|
return unless ($str && $format); |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
7
|
return $class->from_object(scalar Time::Piece::localtime->strptime($str, $format)); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub Time::Moment::from_datetime { |
23
|
2
|
|
|
2
|
0
|
523
|
my ($class, $str) = @_; |
24
|
2
|
50
|
|
|
|
5
|
return unless $str; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
8
|
return $class->strptime($str, $SQL_FORMAT); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub Time::Moment::to_datetime { |
30
|
1
|
|
|
1
|
0
|
272
|
return shift->strftime($SQL_FORMAT); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub Time::Moment::to_date { |
34
|
1
|
|
|
1
|
0
|
303
|
return shift->strftime($SQL_DATE); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub Time::Moment::to_time { |
38
|
1
|
|
|
1
|
0
|
7
|
return shift->strftime($SQL_TIME); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub Time::Moment::day { |
42
|
2
|
|
|
2
|
1
|
1173
|
return shift->day_of_month; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |