| 1 | package SOAP::WSDL::XSD::Typelib::Builtin::dateTime; | ||||||||||
| 2 | 35 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 35 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 35 | ▶ | use Date::Parse; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 35 | ▶ | use Date::Format; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 35 | ▶ | use Class::Std::Fast::Storable constructor => 'none', cache => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 35 | ▶ | use base qw(SOAP::WSDL::XSD::Typelib::Builtin::anySimpleType); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | sub set_value { | ||||||||||
| 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]; | ||||||||
|
Subroutine
set_value: called CC=6 SCAR=18.1
Pod
undocumented
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[-1] ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 3 | $time_str = sprintf( | |||||||||
| 34 | '%04d-%02d-%02dT%02d:%02d:%02d.0000000%+03d:%02d', | ||||||||||
| 35 | $time_from[5] + 1900, | ||||||||||
| 36 | $time_from[4] + 1, | ||||||||||
| 37 | $time_from[3], | ||||||||||
| 38 | $time_from[2], | ||||||||||
| 39 | $time_from[1], | ||||||||||
| 40 | $time_from[0], | ||||||||||
| 41 | int( $time_from[6] / 3600 ), | ||||||||||
| 42 | int( $time_from[6] % 3600 ) / 60 | ||||||||||
| 43 | ); | ||||||||||
| 44 | } | ||||||||||
| 45 | else { | ||||||||||
| 46 | 0 | $time_str = strftime( '%Y-%m-%dT%H:%M:%S%z', @time_from ); | |||||||||
| 47 | 0 | substr $time_str, -2, 0, ':'; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 3 | $_[0]->SUPER::set_value($time_str); | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 35 | 1; | |||||||||