From 502914d29785bf4a4ba6423385979db986c52980 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sat, 9 May 2009 17:47:25 +0000 Subject: Bug 490673: WebServices's datetime_format method was in the wrong module Patch by Max Kanat-Alexander r=wicked, r=ghendricks, a=mkanat --- Bugzilla/WebService.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'Bugzilla/WebService.pm') diff --git a/Bugzilla/WebService.pm b/Bugzilla/WebService.pm index ffaf7c4b7..75fcf6bc9 100755 --- a/Bugzilla/WebService.pm +++ b/Bugzilla/WebService.pm @@ -36,11 +36,24 @@ sub login_exempt { sub type { my ($self, $type, $value) = @_; if ($type eq 'dateTime') { - $value = $self->datetime_format($value); + $value = datetime_format($value); } return XMLRPC::Data->type($type)->value($value); } +sub datetime_format { + my ($date_string) = @_; + + my $time = str2time($date_string); + my ($sec, $min, $hour, $mday, $mon, $year) = localtime $time; + # This format string was stolen from SOAP::Utils->format_datetime, + # which doesn't work but which has almost the right format string. + my $iso_datetime = sprintf('%d%02d%02dT%02d:%02d:%02d', + $year + 1900, $mon + 1, $mday, $hour, $min, $sec); + return $iso_datetime; +} + + 1; __END__ -- cgit v1.2.3-24-g4f1b