summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-09-18 07:10:02 +0200
committerByron Jones <glob@mozilla.com>2014-09-18 07:10:02 +0200
commit4c16c871729ac606501c682419a9fd5d83727ae6 (patch)
tree8a48de9e6f735d10b1e7a6a250dffa2440dc14f3 /Bugzilla
parentc8c2d8e219c8da48c547a15c227dcf934b2d7b57 (diff)
downloadbugzilla-4c16c871729ac606501c682419a9fd5d83727ae6.tar.gz
bugzilla-4c16c871729ac606501c682419a9fd5d83727ae6.tar.xz
Bug 1068014: skip strptime() in datetime_from() if the date is in a standard format
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Util.pm11
1 files changed, 8 insertions, 3 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 6a89cf4fc..2349dc9e9 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -548,9 +548,14 @@ sub datetime_from {
# In the database, this is the "0" date.
return undef if $date =~ /^0000/;
- # strptime($date) returns an empty array if $date has an invalid
- # date format.
- my @time = strptime($date);
+ my @time;
+ # Most dates will be in this format, avoid strptime's generic parser
+ if ($date =~ /^(\d{4})[\.-](\d{2})[\.-](\d{2})(?: (\d{2}):(\d{2}):(\d{2}))?$/) {
+ @time = ($6, $5, $4, $3, $2 - 1, $1 - 1900, undef);
+ }
+ else {
+ @time = strptime($date);
+ }
unless (scalar @time) {
# If an unknown timezone is passed (such as MSK, for Moskow),