Kaydet (Commit) 657420a4 authored tarafından Aanand Prasad's avatar Aanand Prasad

Enforce UTC datetimes in arguments to `events()`

Signed-off-by: 's avatarAanand Prasad <aanand.prasad@gmail.com>
üst 946eb964
......@@ -333,9 +333,9 @@ def convert_filters(filters):
return json.dumps(result)
def datetime_to_timestamp(dt=datetime.now()):
"""Convert a datetime in local timezone to a unix timestamp"""
delta = dt - datetime.fromtimestamp(0)
def datetime_to_timestamp(dt):
"""Convert a UTC datetime to a Unix timestamp"""
delta = dt - datetime.utcfromtimestamp(0)
return delta.seconds + delta.days * 24 * 3600
......
......@@ -251,8 +251,8 @@ function return a blocking generator you can iterate over to retrieve events as
**Params**:
* since (datetime or int): get events from this point
* until (datetime or int): get events until this point
* since (UTC datetime or int): get events from this point
* until (UTC datetime or int): get events until this point
* filters (dict): filter the events by event time, container or image
* decode (bool): If set to true, stream will be decoded into dicts on the
fly. False by default.
......
......@@ -221,7 +221,7 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
def test_events_with_since_until(self):
ts = 1356048000
now = datetime.datetime.fromtimestamp(ts)
now = datetime.datetime.utcfromtimestamp(ts)
since = now - datetime.timedelta(seconds=10)
until = now + datetime.timedelta(seconds=10)
try:
......
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