diff options
author | Byron Jones <glob@mozilla.com> | 2014-09-18 13:10:01 +0800 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2014-09-18 13:10:01 +0800 |
commit | af46080505c3103888846c59551f41e0af823bb1 (patch) | |
tree | 7142a82b007088e919f3d77f13a65939fa3116bd /Bugzilla | |
parent | 1bead98c517f658b17d42f2f79d8ce80317a7040 (diff) | |
download | bugs-af46080505c3103888846c59551f41e0af823bb1.tar bugs-af46080505c3103888846c59551f41e0af823bb1.tar.gz bugs-af46080505c3103888846c59551f41e0af823bb1.tar.bz2 bugs-af46080505c3103888846c59551f41e0af823bb1.tar.xz bugs-af46080505c3103888846c59551f41e0af823bb1.zip |
Bug 1068014: skip strptime() in datetime_from() if the date is in a standard format
r=dylan,a=glob
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Util.pm | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index be65b46c6..670f5f8f2 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -552,9 +552,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), |