Coverage for cmds/time.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2time.py
4contains time()
5"""
7import datetime
8import pytz
10import error
13async def time(*args):
14 """
15 time()
17 returns time at timezone
18 """
20 # fix args
21 args = args[1:]
23 # checks for excess arguments
24 if len(args) > 1:
25 raise error.UnknownArgumentError
27 # checks for argument
28 if len(args) == 1:
30 # checks timezone
31 if args[0] not in pytz.all_timezones:
32 raise error.TimezoneNotFoundError
34 # sets timezone
35 timezone = args[0]
37 else:
38 # sets default timezone
39 timezone = 'UTC'
41 # returns output
42 return datetime.datetime.now(pytz.timezone(timezone)).strftime("%A %Y %B %d %H:%M:%S %Z %z")