Skip to content
Browse files

Merge branch 'master' of git://github.com/rndmcnlly/ShortWiki

  • Loading branch information...
2 parents 00d5d75 + b2f75f9 commit aad0287cec894c5db25943656498f57ae53e160e @progrium progrium committed
Showing with 15 additions and 2 deletions.
  1. +15 −2 shortwiki.py
View
17 shortwiki.py
@@ -96,10 +96,23 @@ def do_read(read, wiki):
content = entry['content']
delay = int(time.time()) - entry['mtime']
author = entry['author']
- send_response(src, "%s %s/%ds" % (content, author, delay))
+ send_response(src, "%s %s/%s" % (content, author, delay_gist(delay)))
else:
send_response(src, '~')
-
+
+def delay_gist(seconds):
+ if seconds < 60:
+ return "%ds" % int(seconds)
+ if seconds < 3600:
+ return "%dm" % int(seconds/60)
+ if seconds < 86400:
+ return "%dh" % int(seconds/3600)
+ if seconds < 2629743.83:
+ return "%dd" % int(seconds/86400)
+ if seconds < 31556929:
+ return "%dmo" % int(seconds/2629743.83)
+ else:
+ return "%dyr" % int(seconds/31556929)
def send_response(dst, payload):
voice.send_sms(dst, payload)

0 comments on commit aad0287

Please sign in to comment.
Something went wrong with that request. Please try again.