From: miker Date: Mon, 27 Mar 2006 17:37:43 +0000 (+0000) Subject: only handle timezone if there was actually a time X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6c54121f87bede01b22d73938c0c90659823e8bc;p=opensrf%2Fbjwebb.git only handle timezone if there was actually a time git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@672 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perlmods/OpenSRF/Utils.pm b/src/perlmods/OpenSRF/Utils.pm index 845c3aa..44ddcd2 100644 --- a/src/perlmods/OpenSRF/Utils.pm +++ b/src/perlmods/OpenSRF/Utils.pm @@ -365,29 +365,30 @@ sub clense_ISO8601 { if ($date =~/(?:$new_date).(\d{2}):(\d{2}):(\d{2})/o) { $new_date .= "T$1:$2:$3"; - } else { - $new_date .= "T00:00:00"; - } - my $z; - if ($date =~ /([-+]{1})([0-9]{1,2})(?::?([0-9]{1,2}))*\s*$/o) { - $z = sprintf('%s%0.2d%0.2d',$1,$2,$3) + my $z; + if ($date =~ /([-+]{1})([0-9]{1,2})(?::?([0-9]{1,2}))*\s*$/o) { + $z = sprintf('%s%0.2d%0.2d',$1,$2,$3) + } else { + $z = DateTime::TimeZone::offset_as_string( + DateTime::TimeZone + ->new( name => 'local' ) + ->offset_for_datetime( + $date_parser->parse_datetime($new_date) + ) + ); + } + + if (length($z) > 3 && index($z, ':') == -1) { + substr($z,3,0) = ':'; + substr($z,6,0) = ':' if (length($z) > 6); + } + + $new_date .= $z; } else { - $z = DateTime::TimeZone::offset_as_string( - DateTime::TimeZone - ->new( name => 'local' ) - ->offset_for_datetime( - $date_parser->parse_datetime($new_date) - ) - ); + $new_date .= "T00:00:00"; } - if (length($z) > 3 && index($z, ':') == -1) { - substr($z,3,0) = ':'; - substr($z,6,0) = ':' if (length($z) > 6); - } - - $new_date .= $z; return $new_date; } return $date;