only handle timezone if there was actually a time
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 27 Mar 2006 17:37:43 +0000 (17:37 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Mon, 27 Mar 2006 17:37:43 +0000 (17:37 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@672 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/Utils.pm

index 845c3aa..44ddcd2 100644 (file)
@@ -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;