| 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
| |||||||||||
| 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
| |||||||||||
| 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; | |||||||||