瀏覽代碼

Give an error if the timestamp is in the future.

pull/15/head
Ben Kurtovic 11 年之前
父節點
當前提交
f323117ba5
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. +3
    -1
      tasks/drn_clerkbot.py

+ 3
- 1
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


Loading…
取消
儲存