Structured/Component/Date.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod n/a totaltotal 0.0% 0 / 36 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Log::Message::Structured::Component::Date;
2 use Moose::Role;
3 use namespace::autoclean;
4  
5 use DateTime;
6 use MooseX::Types::ISO8601 qw/ ISO8601DateTimeStr /;
7  
8 my $GETOPT = do { local $@; eval { require MooseX::Getopt; 1 } };
9  
10 has epochtime => (
11 isa => 'Int',
12 is => 'ro',
13 default => sub { time() },
14 $GETOPT ? ( traits => [qw/ NoGetopt /] ) : (),
15 );
16  
17 has date => (
18 is => 'ro',
19 isa => ISO8601DateTimeStr,
20 lazy => 1,
21 default => sub { DateTime->from_epoch(epoch => shift()->epochtime) },
22 coerce => 1,
23 $GETOPT ? ( traits => [qw/ NoGetopt /] ) : (),
24 );
25  
26 after BUILD => sub { shift()->date };
27  
28 1;
29  
30 __END__