| 1 | package SOAP::WSDL::XSD::Typelib::Builtin::dateTime; | ||||||||||
| 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 | 8 | ▶ | sub set_value { | ||||||||
|
Subroutine
set_value: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||
| 11 | |||||||||||
| 12 | # use set_value from base class if we have a XML-DateTime format | ||||||||||
| 13 | #2037-12-31T00:00:00.0000000+01:00 | ||||||||||
| 14 | 8 | ▶ | return $_[0]->SUPER::set_value( $_[1] ) if not defined $_[1]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 7 | ▶ | return $_[0]->SUPER::set_value( $_[1] ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | if ( | ||||||||||
| 17 | $_[1] =~ m{ ^\d{4} \- \d{2} \- \d{2} | ||||||||||
| 18 | T \d{2} \: \d{2} \: \d{2} (:? \. \d{1,7} )? | ||||||||||
| 19 | [\+\-] \d{2} \: \d{2} $ | ||||||||||
| 20 | }xms | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | # strptime sets empty values to undef - and strftime doesn't like that... | ||||||||||
| 24 | 6 | my @time_from = strptime( $_[1] ); | |||||||||
| 25 | |||||||||||
| 26 | 6 | ▶ | die "Illegal date" if not defined $time_from[5]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | |||||||||||
| 28 | # strftime doesn't like undefs | ||||||||||
| 29 | 3 | ▶ | @time_from = map { !defined $_ ? 0 : $_ } @time_from; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 3 | my $time_str; | |||||||||
| 32 | 3 | ▶ | if ( $time_from[6] ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | # if we parsed a timezone | ||||||||||
| 34 | # don't think this works, ever. if this path is taken, we wind up with something like 2007-08-31T00:32:00.0000000+00:00. | ||||||||||
| 35 | 0 | $time_str = sprintf( | |||||||||
| 36 | '%04d-%02d-%02dT%02d:%02d:%02d.0000000%+03d:%02d', | ||||||||||
| 37 | $time_from[5] + 1900, | ||||||||||
| 38 | $time_from[4] + 1, | ||||||||||
| 39 | $time_from[3], | ||||||||||
| 40 | $time_from[2], | ||||||||||
| 41 | $time_from[1], | ||||||||||
| 42 | $time_from[0], | ||||||||||
| 43 | int( $time_from[6] / 3600 ), | ||||||||||
| 44 | int( $time_from[6] % 3600 ) / 60 | ||||||||||
| 45 | ); | ||||||||||
| 46 | } | ||||||||||
| 47 | else { | ||||||||||
| 48 | 3 | $time_str = strftime( '%Y-%m-%dT%H:%M:%S%z', @time_from ); | |||||||||
| 49 | 3 | substr $time_str, -2, 0, ':'; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | 3 | $_[0]->SUPER::set_value($time_str); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 37 | 1; | |||||||||