Commit 29eb6e62 authored by deymo@chromium.org's avatar deymo@chromium.org

my_activity.py: Parse rietveld dates without milliseconds.

Sometimes rietveld returns a datetime without the milliseconds part,
presumably when it is 0. This patch fixes the parsing of those cases.

BUG=chromium:323615
TEST=Ran "my_activity.py --week_of 11/18/13 --user jsbell" which returns "2013-11-18 20:42:30" for a bug.

Review URL: https://codereview.chromium.org/204013009

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@258189 0039d316-1c4b-4281-b951-d872f2087c98
parent 174772e0
...@@ -191,7 +191,12 @@ def datetime_from_gerrit(date_string): ...@@ -191,7 +191,12 @@ def datetime_from_gerrit(date_string):
def datetime_from_rietveld(date_string): def datetime_from_rietveld(date_string):
return datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S.%f') try:
return datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S.%f')
except ValueError:
# Sometimes rietveld returns a value without the milliseconds part, so we
# attempt to parse those cases as well.
return datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S')
def datetime_from_google_code(date_string): def datetime_from_google_code(date_string):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment