File Coverage

blib/lib/XML/SRS/Time.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1              
2             package XML::SRS::Time;
3              
4 1     1   1502 use Moose::Role;
  0            
  0            
5             use PRANG::Graph;
6             use Moose::Util::TypeConstraints;
7             use MooseX::Method::Signatures;
8              
9             BEGIN{
10             subtype 'XML::SRS::Time::Hour'
11             => as "Int",
12             => where {
13             $_ >= 0 and $_ <= 23;
14             };
15             subtype 'XML::SRS::Time::Sexagesimal'
16             => as "Int",
17             => where {
18             $_ >= 0 and $_ <= 59;
19             };
20             subtype 'XML::SRS::Time::TZOffset'
21             => as "Str",
22             => where {
23             m{^[-+][\s\d]?\d(?::?\d\d)?$};
24              
25             };
26              
27             subtype 'XML::SRS::Time::hms'
28             => as "Str",
29             => where {
30             m{^(\d{1,2}):(\d{1,2}):(\d{1,2})$};
31             };
32             }
33              
34             method buildargs_time($inv: XML::SRS::Time::hms $hms, Maybe[XML::SRS::Time::TZOffset] $offset?) {
35             my @buildargs;
36             if (defined $offset) {
37             push @buildargs, tz_offset => $offset;
38             }
39             my ($h, $m, $s) = split ":", $hms;
40             push @buildargs, hour => $h, minute => $m, second => $s;
41             @buildargs;
42             }
43              
44             has_attr 'hour' =>
45             is => "rw",
46             isa => "XML::SRS::Time::Sexagesimal",
47             required => 1,
48             xml_name => "Hour",
49             ;
50              
51             has_attr 'minute' =>
52             is => "rw",
53             isa => "XML::SRS::Time::Sexagesimal",
54             required => 1,
55             xml_name => "Minute",
56             ;
57              
58             has_attr 'second' =>
59             is => "rw",
60             isa => "XML::SRS::Time::Sexagesimal",
61             xml_name => "Second",
62             ;
63              
64             has_attr 'tz_offset' =>
65             is => "rw",
66             isa => "XML::SRS::Time::TZOffset",
67             xml_required => 0,
68             clearer => "make_floating",
69             xml_name => "TimeZoneOffset",
70             ;
71              
72             1;