From 9a9405da0b6b5baf8157206d34ba3895fb33b788 Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Thu, 4 Mar 2010 14:28:32 -0500 Subject: Bug 545299, XML-RPC WebService should take and return dates and times in UTC. Code part, r+=mkanat --- Bugzilla/WebService/Bugzilla.pm | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'Bugzilla/WebService/Bugzilla.pm') diff --git a/Bugzilla/WebService/Bugzilla.pm b/Bugzilla/WebService/Bugzilla.pm index 6e74900b9..a66871dc6 100644 --- a/Bugzilla/WebService/Bugzilla.pm +++ b/Bugzilla/WebService/Bugzilla.pm @@ -21,6 +21,7 @@ package Bugzilla::WebService::Bugzilla; use strict; use base qw(Bugzilla::WebService); use Bugzilla::Constants; +use Bugzilla::Util qw(datetime_from); use DateTime; @@ -49,32 +50,27 @@ sub extensions { sub timezone { my $self = shift; - my $offset = Bugzilla->local_timezone->offset_for_datetime(DateTime->now()); - $offset = (($offset / 60) / 60) * 100; - $offset = sprintf('%+05d', $offset); - return { timezone => $self->type('string', $offset) }; + # All Webservices return times in UTC; Use UTC here for backwards compat. + return { timezone => $self->type('string', "+0000") }; } sub time { my ($self) = @_; + # All Webservices return times in UTC; Use UTC here for backwards compat. + # Hardcode values where appropriate my $dbh = Bugzilla->dbh; my $db_time = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); + $db_time = datetime_from($db_time, 'UTC'); my $now_utc = DateTime->now(); - my $tz = Bugzilla->local_timezone; - my $now_local = $now_utc->clone->set_time_zone($tz); - my $tz_offset = $tz->offset_for_datetime($now_local); - return { db_time => $self->type('dateTime', $db_time), - web_time => $self->type('dateTime', $now_local), + web_time => $self->type('dateTime', $now_utc), web_time_utc => $self->type('dateTime', $now_utc), - tz_name => $self->type('string', $tz->name), - tz_offset => $self->type('string', - $tz->offset_as_string($tz_offset)), - tz_short_name => $self->type('string', - $now_local->time_zone_short_name), + tz_name => $self->type('string', 'UTC'), + tz_offset => $self->type('string', '+0000'), + tz_short_name => $self->type('string', 'UTC'), }; } -- cgit v1.2.3-24-g4f1b