Added support for Swatch Internet Time (.beats)

This commit is contained in:
Luke Rogers 2012-10-20 12:09:56 +13:00
parent ec77c141b9
commit 743c13a353

View file

@ -1,7 +1,5 @@
# Plugin by Lukeroge
from util import hook
from util import http
from util import hook, http
import time
from util.text import capitalize_first
api_url = 'http://api.wolframalpha.com/v2/query?format=plaintext'
@ -32,3 +30,29 @@ def time_command(inp, bot=None):
return "%s - \x02%s\x02" % (time, place)
else:
return "Could not get the time for '%s'." % inp
@hook.command(autohelp=False)
def beats(inp):
"beats -- Gets the current time in .beats (Swatch Internet Time). "
if inp.lower() == "wut":
return "Instead of hours and minutes, the mean solar day is divided " \
"up into 1000 parts called \".beats\". Each .beat lasts 1 minute and" \
" 26.4 seconds. Times are notated as a 3-digit number out of 1000 af" \
"ter midnight. So, @248 would indicate a time 248 .beats after midni" \
"ght representing 248/1000 of a day, just over 5 hours and 57 minute" \
"s. There are no timezones."
t = time.gmtime()
h, m, s = t.tm_hour, t.tm_min, t.tm_sec
utc = 3600 * h + 60 * m + s
bmt = utc + 3600 # Biel Mean Time (BMT)
beat = bmt / 86.4
if beat > 1000:
beat -= 1000
return "\x02Swatch Internet Time:\x02 @%06.2f" % beat