blib/lib/SOAP/WSDL/XSD/Typelib/Builtin/time.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 97.6% 41 / 42 CC 3 SCAR 5.1
CC
3
Cov
100%
set_value
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.7
« blib/lib/SOAP/WSDL/XSD/Typelib/Builtin/string.pm ↑ Summary blib/lib/SOAP/WSDL/Definitions.pm »
1 package SOAP::WSDL::XSD::Typelib::Builtin::time;
2 37 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 37 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 37 ▶use Date::Parse;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 37 ▶use Date::Format;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 37 ▶use Class::Std::Fast::Storable constructor => 'none', cache => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 37 ▶use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 37 our $VERSION = 3.004;
10  
11 2 ▶sub set_value {
Subroutine set_value: called CC=3 SCAR=11.0
Pod undocumented
12 # use set_value from base class if we have a XML-Time format
13 # 00:00:00.0000000+01:00
14 2 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1] =~ / ^ \d{2} \: \d{2} \: \d{2} (:? \. \d{1,7} )? [\+\-] \d{2} \: \d{2} $ /msx) { } 1 1 2
15 $_[1] =~ m{ ^ \d{2} \: \d{2} \: \d{2} (:? \. \d{1,7} )?
16 [\+\-] \d{2} \: \d{2} $
17 }xms
18 ) {
19 1 $_[0]->SUPER::set_value($_[1])
20 }
21 # use a combination of strptime and strftime for converting the date
22 # Unfortunately, strftime outputs the time zone as [+-]0000, whereas XML
23 # whants it as [+-]00:00
24 # We leave out the optional nanoseconds part, as it would always be empty.
25 else {
26 # strptime sets empty values to undef - and strftime doesn't like that...
27 # we even need to set it to 1 to prevent a "Day '0' out of range 1..31" warning..
28  
29 # we need to set the current date for correct TZ conversion -
30 # could be daylight savings time
31 1 my @now = localtime;
32 1 my @time_from = map { my $alternative = shift @now;
33 8 ▶ ! defined $_
Branch: 1 branch
BranchTrueFalseTotal
!defined($_) ? : 5 3 8
34 ? $alternative
35 : $_ } strptime($_[1]);
36 1 undef $time_from[-1];
37 1 my $time_str = strftime( '%H:%M:%S%z', @time_from );
38 1 substr $time_str, -2, 0, ':';
39 1 $_[0]->SUPER::set_value($time_str);
40 }
41 }
42  
43 37 1;
« blib/lib/SOAP/WSDL/XSD/Typelib/Builtin/string.pm ↑ Summary blib/lib/SOAP/WSDL/Definitions.pm »