Skip to content

Commit dc7f082

Browse files
authored
Merge pull request #76 from robinmahieu/development
misc fixes
2 parents 2307dfc + e3f678d commit dc7f082

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

brawlstats/models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ def get_club(self) -> Club:
9494
A list of the members in a club, or None if the player is not in a club.
9595
"""
9696
if not self.club:
97+
if self.client.is_async:
98+
async def wrapper():
99+
return None
100+
return wrapper()
97101
return None
102+
98103
url = '{}/{}'.format(self.client.api.CLUB, bstag(self.club.tag))
99104
return self.client._get_model(url, model=Club)
100105

brawlstats/utils.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ def bstag(tag):
4444
return tag
4545

4646

47-
def get_datetime(timestamp: str, unix: bool=True) -> Union[int, datetime.datetime]:
47+
def get_datetime(timestamp: str, unix: bool=True) -> Union[int, datetime]:
4848
"""Converts a %Y%m%dT%H%M%S.%fZ to a UNIX timestamp or a datetime.datetime object
4949
5050
Parameters
5151
----------
5252
timestamp : str
53-
A timestamp in the %Y-%m-%dT%H:%M:%S.%fZ format, usually returned by the API
54-
in the ``created_time`` field for example (eg. 2018-07-18T14:59:06.000Z)
53+
A timestamp in the %Y%m%dT%H%M%S.%fZ format, usually returned by the API in the
54+
``battleTime`` field in battle log responses - e.g., 20200925T184431.000Z
5555
unix : bool, optional
5656
Whether to return a POSIX timestamp (seconds since epoch) or not, by default True
5757
@@ -60,11 +60,12 @@ def get_datetime(timestamp: str, unix: bool=True) -> Union[int, datetime.datetim
6060
Union[int, datetime.datetime]
6161
If unix=True it will return int, otherwise datetime.datetime
6262
"""
63-
time = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
63+
time = datetime.strptime(timestamp, '%Y%m%dT%H%M%S.%fZ')
64+
6465
if unix:
6566
return int(time.timestamp())
66-
else:
67-
return time
67+
68+
return time
6869

6970

7071
def nothing(value):

0 commit comments

Comments
 (0)