From 7d01cb036c10487b653fd5a74a64f38093a863c7 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Thu, 5 Feb 2009 18:37:16 +0000 Subject: [PATCH] =?utf8?q?Bug=20476889:=20importxml.pl=20crashes=20when=20?= =?utf8?q?importing=20bugs=20(Date::Parse::strptime()=20leave=20seconds=20?= =?utf8?q?undefined=20in=20some=20cases)=20-=20Patch=20by=20Fr=C3=83=C2=A9?= =?utf8?q?d=C3=83=C2=A9ric=20Buclin=20=20r=3Dghendricks?= =?utf8?q?=20a=3DLpSolit?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Bugzilla/Util.pm | 3 +++ importxml.pl | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 951c4df3c8..3573ad1480 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -444,6 +444,9 @@ sub format_time { my @time = strptime($date); if (scalar @time) { + # Fix a bug in strptime() where seconds can be undefined in some cases. + $time[0] ||= 0; + # strptime() counts years from 1900, and months from 0 (January). # We have to fix both values. my $dt = DateTime->new({year => 1900 + $time[5], diff --git a/importxml.pl b/importxml.pl index fd8c27723d..08bf06c93c 100755 --- a/importxml.pl +++ b/importxml.pl @@ -567,7 +567,7 @@ sub process_bug { my $comments; $comments .= "\n\n--- Bug imported by $exporter_login "; - $comments .= format_time(localtime(time()), '%Y-%m-%d %H:%M %Z') . " "; + $comments .= format_time(scalar localtime(time()), '%Y-%m-%d %R %Z') . " "; $comments .= " ---\n\n"; $comments .= "This bug was previously known as _bug_ $bug_fields{'bug_id'} at "; $comments .= $urlbase . "show_bug.cgi?id=" . $bug_fields{'bug_id'} . "\n"; -- 2.47.2