Skip to content

Commit

Permalink
improve datetime parsing
Browse files Browse the repository at this point in the history
make it less error-prone, b/c apparently docker is able to return really
wild values:

ValueError: unconverted data remains: Z

Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
  • Loading branch information
TomasTomecek committed Mar 18, 2017
1 parent 19fcaed commit 045a62e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sen/docker_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,12 @@ def started_at(self):
s = s[:26]
if s == "0001-01-01T00:00:00Z":
return DINOSAUR_TIME
started_at = datetime.datetime.strptime(s, ISO_DATETIME_PARSE_STRING)
s = s.replace("Z", "0")
try:
started_at = datetime.datetime.strptime(s, ISO_DATETIME_PARSE_STRING)
except ValueError as ex:
logger.error("unable to parse datetime %s: %s", s, ex)
return DINOSAUR_TIME
return started_at

@property
Expand Down

0 comments on commit 045a62e

Please sign in to comment.