diff options
author | 2021-08-07 11:01:30 -0700 | |
---|---|---|
committer | 2021-08-07 11:01:30 -0700 | |
commit | 38e0789890ce9d3c7307de158c9277f6aa20b848 (patch) | |
tree | 6fa3930d2b1f16359cdb28378ad7e462f650bd4d | |
parent | Time: return strings from until_expiration instead of ambiguous None (diff) |
Time: check timestamp for None only rather than if it's falsy
Integers and floats which are 0 are considered valid timestamps, but are
falsy.
-rw-r--r-- | bot/utils/time.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/bot/utils/time.py b/bot/utils/time.py index 4b2fbae2c..29fc46d56 100644 --- a/bot/utils/time.py +++ b/bot/utils/time.py @@ -292,9 +292,9 @@ def format_with_duration( `max_units` is forwarded to `time.humanize_delta`. See its documentation for more information. - Return None if `timestamp` is falsy. + Return None if `timestamp` is None. """ - if not timestamp: + if timestamp is None: return None formatted_timestamp = discord_timestamp(timestamp) @@ -309,9 +309,9 @@ def until_expiration(expiry: Optional[Timestamp]) -> str: `expiry` can be any type supported by the single-arg `arrow.get()`, except for a `tzinfo`. - Return "Permanent" if `expiry` is falsy. Return "Expired" if `expiry` is in the past. + Return "Permanent" if `expiry` is None. Return "Expired" if `expiry` is in the past. """ - if not expiry: + if expiry is None: return "Permanent" expiry = arrow.get(expiry) |