line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Tersify::Plugin::DateTime; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
27801
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
61
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
976
|
use DateTime; |
|
2
|
|
|
|
|
511862
|
|
|
2
|
|
|
|
|
365
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000'; |
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
|
1944
|
sub handles { 'DateTime' } |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 tersify |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
It summarises DateTime objects into human-readable representations, using |
37
|
|
|
|
|
|
|
variants of the One True Date format. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
If the time is 00:00:00, it returns I<yyyy-mm-dd>; if there's a more interesing |
40
|
|
|
|
|
|
|
time, it returns I<yyyy-mm-dd hh:mm:ss>. If there's also a non-floating |
41
|
|
|
|
|
|
|
timezone, it returns details of that timezone as well, so |
42
|
|
|
|
|
|
|
I<yyyy-mm-dd hh:mm:ss Time/Zone>. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub tersify { |
47
|
4
|
|
|
4
|
1
|
198
|
my ($self, $datetime) = @_; |
48
|
|
|
|
|
|
|
|
49
|
4
|
|
|
|
|
14
|
my $terse = $datetime->ymd; |
50
|
4
|
100
|
|
|
|
61
|
if ($datetime->hms ne '00:00:00') { |
51
|
2
|
|
|
|
|
25
|
$terse .= ' ' . $datetime->hms; |
52
|
2
|
100
|
|
|
|
18
|
if ($datetime->time_zone->name ne 'floating') { |
53
|
1
|
|
|
|
|
22
|
$terse .= ' ' . $datetime->time_zone->name; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
4
|
|
|
|
|
49
|
return $terse; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|