From 114db9a8388cfda7f293a2ac3354ad39818f3488 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Fri, 10 Apr 2009 22:07:41 +0000 Subject: Bug 487865: Exporting bugs in XML format uses non-unique timezones (they cannot be imported back) - Patch by Frédéric Buclin r=ghendricks a=LpSolit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla/Util.pm | 7 +++++++ template/en/default/bug/show.xml.tmpl | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 398957b13..7ed20c875 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -426,6 +426,13 @@ sub format_time { # strptime($date) returns an empty array if $date has an invalid date format. my @time = strptime($date); + unless (scalar @time) { + # If an unknown timezone is passed (such as MSK, for Moskow), strptime() is + # unable to parse the date. We try again, but we first remove the timezone. + $date =~ s/\s+\S+$//; + @time = strptime($date); + } + if (scalar @time) { # Fix a bug in strptime() where seconds can be undefined in some cases. $time[0] ||= 0; diff --git a/template/en/default/bug/show.xml.tmpl b/template/en/default/bug/show.xml.tmpl index cd7f44eff..cb0b10a42 100644 --- a/template/en/default/bug/show.xml.tmpl +++ b/template/en/default/bug/show.xml.tmpl @@ -79,7 +79,7 @@ [% NEXT IF c.isprivate && !user.in_group(Param("insidergroup")) %] [% c.author.email FILTER email FILTER xml %] - [% c.time FILTER time FILTER xml %] + [% c.time FILTER time("%Y-%m-%d %T %z") FILTER xml %] [% IF user.in_group(Param('timetrackinggroup')) && (c.work_time - 0 != 0) %] [% PROCESS formattimeunit time_unit = c.work_time FILTER xml %] [% END %] @@ -97,7 +97,7 @@ isprivate="[% a.isprivate FILTER xml %]" > [% a.id %] - [% a.attached FILTER time FILTER xml %] + [% a.attached FILTER time("%Y-%m-%d %R %z") FILTER xml %] [% a.description FILTER xml %] [% a.filename FILTER xml %] [% a.contenttype FILTER xml %] @@ -146,7 +146,7 @@ [% ELSIF field == 'cc' %] [% val = val FILTER email %] [% ELSIF field == 'creation_ts' OR field == 'delta_ts' %] - [% val = val FILTER time %] + [% val = val FILTER time("%Y-%m-%d %T %z") %] [% END %] <[% field %][% IF name != '' %] name="[% name FILTER xml %]"[% END -%]> [%- val FILTER xml %] -- cgit v1.2.3-24-g4f1b