line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Tersify::Plugin::DateTime; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
6401
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
57
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
556
|
use DateTime; |
|
2
|
|
|
|
|
392734
|
|
|
2
|
|
|
|
|
264
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
9
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Data::Tersify::Plugin::DateTime - tersify DateTime objects |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use Data::Tersify; |
18
|
|
|
|
|
|
|
print dumper(tersify({ now => DateTime->now })); |
19
|
|
|
|
|
|
|
# Prints just today's date and time in yyyy-mm-ss hh:mm:ss format, |
20
|
|
|
|
|
|
|
# rather than a full screen of DateTime internals |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This class provides terse description for DateTime objects. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 handles |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
It handles DateTime objects only. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
1
|
1422
|
sub handles { 'DateTime' } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 tersify |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
It summarises DateTime objects into either C<yyyy-mm-dd> or |
37
|
|
|
|
|
|
|
C<yyyy-mm-dd hh:mm:ss>, depending on whether there's a time component to the |
38
|
|
|
|
|
|
|
DateTime object or not. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub tersify { |
43
|
2
|
|
|
2
|
1
|
76
|
my ($self, $datetime) = @_; |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
8
|
my $terse = $datetime->ymd; |
46
|
2
|
100
|
|
|
|
33
|
if ($datetime->hms ne '00:00:00') { |
47
|
1
|
|
|
|
|
14
|
$terse .= ' ' . $datetime->hms; |
48
|
|
|
|
|
|
|
} |
49
|
2
|
|
|
|
|
19
|
return $terse; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|