From f323117ba50e36abc35e64db27388723cc76b4db Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 15 Oct 2013 17:57:54 -0400 Subject: [PATCH] Give an error if the timestamp is in the future. --- tasks/drn_clerkbot.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tasks/drn_clerkbot.py b/tasks/drn_clerkbot.py index a65f181..f58a5e0 100644 --- a/tasks/drn_clerkbot.py +++ b/tasks/drn_clerkbot.py @@ -725,9 +725,11 @@ class DRNClerkBot(Task): return row + "|sm={{{small|}}}}}\n" def format_time(self, dt): - """Return a string telling the time since datetime occurred.""" + """Return a string telling the time since *dt* occurred.""" parts = [("year", 31536000), ("day", 86400), ("hour", 3600)] seconds = int((datetime.utcnow() - dt).total_seconds()) + if seconds < 0: + return "Invalid future time" msg = [] for name, size in parts: num = seconds // size