]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 550618: Make the XML-RPC WebService return the right date format
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 8 Mar 2010 07:35:34 +0000 (23:35 -0800)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 8 Mar 2010 07:35:34 +0000 (23:35 -0800)
r=dkl, a=mkanat

Bugzilla/WebService.pm
Bugzilla/WebService/Server.pm

index 6ff75188102c9f938e93e9226ebc087dba17cf9e..2ba8e925e78c0978b04eb74301170a509f1d85f2 100644 (file)
 # actual RPC server, see Bugzilla::WebService::Server and its subclasses.
 package Bugzilla::WebService;
 use strict;
-use Date::Parse;
+use Bugzilla::WebService::Server;
+
 use XMLRPC::Lite;
-use Bugzilla::Util qw(datetime_from);
-use Scalar::Util qw(blessed);
 
 # Used by the JSON-RPC server to convert incoming date fields apprpriately.
 use constant DATE_FIELDS => {};
@@ -43,22 +42,16 @@ sub type {
     return XMLRPC::Data->type($type)->value($value);
 }
 
+# This is the XML-RPC implementation, see the README in Bugzilla/WebService/.
+# Our "base" implementation is in Bugzilla::WebService::Server.
 sub datetime_format_outbound {
-    my ($self, $date) = @_;
-
-    my $time = $date;
-    if (blessed($date)) {
-        # We expect this to mean we were sent a datetime object
-        $time->set_time_zone('UTC');
-    } else {
-        # We always send our time in UTC, for consistency.
-        # passed in value is likely a string, create a datetime object
-        $time = datetime_from($date, 'UTC');
-    }
-    return $time->iso8601();
+    my $self = shift;
+    my $value = Bugzilla::WebService::Server->datetime_format_outbound(@_);
+    # XML-RPC uses an ISO-8601 format that doesn't have any hyphens.
+    $value =~ s/-//g;
+    return $value;
 }
 
-
 1;
 
 __END__
index 21f0f787c25132002712b9bab35942c3e37edb7d..71c790e8e499ac46ac786efbe67734143d59932b 100644 (file)
@@ -21,6 +21,8 @@ use strict;
 use Bugzilla::Error;
 use Bugzilla::Util qw(datetime_from);
 
+use Scalar::Util qw(blessed);
+
 sub handle_login {
     my ($self, $class, $method, $full_method) = @_;
     eval "require $class";
@@ -38,4 +40,19 @@ sub datetime_format_inbound {
     return $time
 }
 
+sub datetime_format_outbound {
+    my ($self, $date) = @_;
+
+    my $time = $date;
+    if (blessed($date)) {
+        # We expect this to mean we were sent a datetime object
+        $time->set_time_zone('UTC');
+    } else {
+        # We always send our time in UTC, for consistency.
+        # passed in value is likely a string, create a datetime object
+        $time = datetime_from($date, 'UTC');
+    }
+    return $time->iso8601();
+}
+
 1;