From 97b69fa2f0a0213bfddfc5540fedf2e4da63c8d2 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Fri, 9 Jan 2009 19:13:32 +0000 Subject: Bug 472224: Bugzilla.time function that returns detailed time and timezone information Patch By Max Kanat-Alexander r=dkl, a=mkanat --- Bugzilla/WebService/Bugzilla.pm | 102 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) (limited to 'Bugzilla/WebService') diff --git a/Bugzilla/WebService/Bugzilla.pm b/Bugzilla/WebService/Bugzilla.pm index 2f35bbe59..b1ab8f34f 100755 --- a/Bugzilla/WebService/Bugzilla.pm +++ b/Bugzilla/WebService/Bugzilla.pm @@ -57,6 +57,29 @@ sub timezone { return { timezone => $self->type('string', $offset) }; } +sub time { + my ($self) = @_; + my $dbh = Bugzilla->dbh; + + my $db_time = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)'); + 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_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), + }; +} + 1; __END__ @@ -129,7 +152,8 @@ extension =item C -B +B This method may be removed in a future version of Bugzilla. +Use L instead. =over @@ -148,4 +172,80 @@ string in (+/-)XXXX (RFC 2822) format. =back + +=item C