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

filter: Statementstmt 100% 31 / 31 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 97.7% 44 / 45 CC 4 SCAR 7.9
CC
4
Cov
100%
set_value
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« blib/lib/SOAP/WSDL/XSD/Schema.pm ↑ Summary blib/lib/SOAP/WSDL/XSD/Typelib/Builtin/anySimpleType.pm »
1 package SOAP::WSDL::XSD::Typelib::Builtin::date;
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  
7 37 ▶use Class::Std::Fast::Storable constructor => 'none', cache => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 37 ▶use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 30 ▶sub set_value {
Subroutine set_value: called CC=4 SCAR=13.9
Pod undocumented
11 # use set_value from base class if we have a XML-DateTime format
12 #2037-12-31+01:00
13 30 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1] =~ / ^\d{4} \- \d{2} \- \d{2} (:? [\+\-] \d{2} \: \d{2} )$ /msx) { } 2 28 30
14 $_[1] =~ m{ ^\d{4} \- \d{2} \- \d{2}
15 (:? [\+\-] \d{2} \: \d{2} )$
16 }xms
17 ) {
18 2 $_[0]->SUPER::set_value($_[1])
19 }
20 # converting a date is hard work: It needs a timezone, because
21 # 2007-12-30+12:00 and 2007-12-31-12:00 mean the same day - just in
22 # different locations.
23 # strftime actually prints out the correct date, but always prints the
24 # local timezone with %z.
25 # So, if our timezone is not 0, we strftime it without timezone and
26 # append it by hand by the following formula:
27 # The timezone hours are the int (timesone seconds / 3600)
28 # The timezone minutes (if someone ever specifies something like that)
29 # are int( (seconds % 3600) / 60 )
30 # say, int( (seconds modulo 3600) / 60 )
31 #
32 # If we have no timezone (meaning the timezone is
33 else {
34 # strptime sets empty values to undef - and strftime doesn't like that...
35 28 my @time_from = strptime($_[1]);
36 28 my $time_zone_seconds = $time_from[6];
37 28 ▶ @time_from = map { (! defined $_) ? 0 : $_ } @time_from;
Branch: 1 branch
BranchTrueFalseTotal
!defined($_) ? : 12 212 224
38 # use Data::Dumper;
39 # warn Dumper \@time_from, sprintf('%+03d%02d', $time_from[6] / 3600, $time_from[6] % 60 );
40 28 my $time_str;
41 28 ▶ if (defined $time_zone_seconds) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $time_zone_seconds) { } 25 3 28
42 25 $time_str = sprintf('%04d-%02d-%02d%+03d:%02d', $time_from[5]+1900, $time_from[4]+1, $time_from[3], int($time_from[6] / 3600), int($time_from[6] % 3600) / 60);
43 }
44 else {
45 3 $time_str = strftime( '%Y-%m-%d%z', @time_from );
46 3 substr $time_str, -2, 0, ':';
47 }
48  
49 # ? strftime( '%Y-%m-%d', @time_from )
50 # . sprintf('%+03d%02d', int($time_from[6] / 3600), int ( ($time_from[6] % 3600) / 60 ) )
51 # : do {
52 # strftime( '%Y-%m-%d%z', @time_from );
53 # };
54 # substr $time_str, -2, 0, ':';
55 28 $_[0]->SUPER::set_value($time_str);
56 }
57 }
58  
59 37 1;
60  
« blib/lib/SOAP/WSDL/XSD/Schema.pm ↑ Summary blib/lib/SOAP/WSDL/XSD/Typelib/Builtin/anySimpleType.pm »