PEP8 baby! (my pep8 says it does need a space in 'CAT':-10, so I re-added them
This commit is contained in:
parent
d39fdc51af
commit
cb742f4e93
1 changed files with 125 additions and 118 deletions
|
@ -98,8 +98,8 @@ TZ2 = {
|
|||
'ACDT': 10.5,
|
||||
'ACST': 9.5,
|
||||
'ADT': 3,
|
||||
'AEDT': 11, # hmm
|
||||
'AEST': 10, # hmm
|
||||
'AEDT': 11,
|
||||
'AEST': 10,
|
||||
'AHDT': 9,
|
||||
'AHST': 10,
|
||||
'AST': 4,
|
||||
|
@ -191,31 +191,38 @@ TimeZones.update(TZ3)
|
|||
|
||||
r_local = re.compile(r'\([a-z]+_[A-Z]+\)')
|
||||
|
||||
|
||||
# gets the time from a timezone (code from phenny)
|
||||
def get_time(tz):
|
||||
TZ = tz.upper()
|
||||
|
||||
if (TZ == 'UTC') or (TZ == 'Z'):
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02 GMT", time.gmtime())
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02 "
|
||||
"GMT", time.gmtime())
|
||||
return msg
|
||||
elif r_local.match(tz): # thanks to Mark Shoulsdon (clsn)
|
||||
elif r_local.match(tz):
|
||||
locale.setlocale(locale.LC_TIME, (tz[1:-1], 'UTF-8'))
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(TZ), time.gmtime())
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02"
|
||||
+ str(TZ), time.gmtime())
|
||||
return msg
|
||||
elif TimeZones.has_key(TZ):
|
||||
elif TZ in TimeZones:
|
||||
offset = TimeZones[TZ] * 3600
|
||||
timenow = time.gmtime(time.time() + offset)
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02" + str(TZ), timenow)
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in \x02"
|
||||
+ str(TZ), timenow)
|
||||
return msg
|
||||
elif tz and tz[0] in ('+', '-') and 4 <= len(tz) <= 6:
|
||||
timenow = time.gmtime(time.time() + (int(tz[:3]) * 3600))
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02 GMT" + str(tz), timenow)
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02"
|
||||
" GMT" + str(tz), timenow)
|
||||
return msg
|
||||
else:
|
||||
timenow = time.gmtime(time.time() + (int(tz) * 3600))
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02 GMT " + str(tz), timenow)
|
||||
msg = time.strftime("\x02%I:%M%p\x02 %A - \x02Time\x02 in\x02"
|
||||
" GMT " + str(tz), timenow)
|
||||
return msg
|
||||
|
||||
|
||||
@hook.command("time")
|
||||
def timecommand(inp, say=None):
|
||||
".time <area> -- Gets the time in <area>"
|
||||
|
|
Reference in a new issue