line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Time::Moment::Ext; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
965
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
46
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
41
|
|
5
|
2
|
|
|
2
|
|
624
|
use Time::Piece (); |
|
2
|
|
|
|
|
14508
|
|
|
2
|
|
|
|
|
48
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
14
|
use parent 'Time::Moment'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
9
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
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 Time::Piece::localtime->strptime($str, $format)); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub Time::Moment::from_datetime { |
23
|
2
|
|
|
2
|
0
|
457
|
my ($class, $str) = @_; |
24
|
2
|
50
|
|
|
|
6
|
return unless $str; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
7
|
return $class->strptime($str, $SQL_FORMAT); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub Time::Moment::to_datetime { |
30
|
1
|
|
|
1
|
0
|
245
|
return shift->strftime($SQL_FORMAT); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub Time::Moment::to_date { |
34
|
1
|
|
|
1
|
0
|
348
|
return shift->strftime($SQL_DATE); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub Time::Moment::to_time { |
38
|
1
|
|
|
1
|
0
|
9
|
return shift->strftime($SQL_TIME); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub Time::Moment::day { |
42
|
2
|
|
|
2
|
1
|
1169
|
return shift->day_of_month; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |