Skip to content

Commit

Permalink
Consider timezone when parsing docker's timestamp
Browse files Browse the repository at this point in the history
When the plugin and the docker host is running in different timezones e.g: the
plugin runs inside a container with UTC timezone while the host is in some local
timezone, the plugin will converts the time string reported by docker into a
wrong unix timestamp.
  • Loading branch information
bullno1 committed Apr 1, 2016
1 parent a432f8a commit ca7db7f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dockerplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import dateutil.parser
from distutils.version import StrictVersion
import calendar
import docker
import os
import threading
Expand Down Expand Up @@ -58,7 +59,7 @@ def emit(cls, container, type, value, t=None, type_instance=None):
val.type_instance = type_instance

if t:
val.time = time.mktime(dateutil.parser.parse(t).timetuple())
val.time = calendar.timegm(dateutil.parser.parse(t).utctimetuple())
else:
val.time = time.time()

Expand Down

0 comments on commit ca7db7f

Please sign in to comment.