From 6c47fa77b66fff56e3c805dfe989ffeccae49bca Mon Sep 17 00:00:00 2001 From: Rishi Gupta Date: Sat, 25 Feb 2017 13:11:53 -0800 Subject: [PATCH] Use time.time() instead of datetime.now() to measure elapsed time. Both because it is more idiomatic and because we will soon start enforcing that all datetimes in Zulip are timezone aware. --- bots/zephyr_mirror_backend.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bots/zephyr_mirror_backend.py b/bots/zephyr_mirror_backend.py index 386e078..6ee08b2 100755 --- a/bots/zephyr_mirror_backend.py +++ b/bots/zephyr_mirror_backend.py @@ -38,6 +38,7 @@ import optparse import os import datetime import textwrap +import time import signal import logging import hashlib @@ -762,8 +763,8 @@ def maybe_forward_to_zephyr(message): # Don't try forward private messages with non-MIT users # to MIT Zephyr. return - timestamp_now = datetime.datetime.now().strftime("%s") - if float(message["timestamp"]) < float(timestamp_now) - 15: + timestamp_now = int(time.time()) + if float(message["timestamp"]) < timestamp_now - 15: logger.warning("Skipping out of order message: %s < %s" % (message["timestamp"], timestamp_now)) return