diff options
| author | 2021-08-05 16:35:41 -0700 | |
|---|---|---|
| committer | 2021-08-05 16:35:41 -0700 | |
| commit | 3ac1ef92b928c26985342a3f35934a1c7c08d2b4 (patch) | |
| tree | 628b41e8999dac6ee8fd8303ff46d625818633cc | |
| parent | Time: replace discord_timestamp calls with format_relative (diff) | |
Time: remove absolute param from format_infraction_with_duration
It's not used anywhere. Furthermore, a humanised duration with negative
values wouldn't make sense.
| -rw-r--r-- | bot/utils/time.py | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/bot/utils/time.py b/bot/utils/time.py index da56bcea8..190adf885 100644 --- a/bot/utils/time.py +++ b/bot/utils/time.py @@ -180,16 +180,12 @@ def format_infraction_with_duration( date_to: Optional[str], date_from: Optional[datetime.datetime] = None, max_units: int = 2, - absolute: bool = True ) -> Optional[str]: """ Return `date_to` formatted as a discord timestamp with the timestamp duration since `date_from`. `max_units` specifies the maximum number of units of time to include in the duration. For example, a value of 1 may include days but not hours. - - If `absolute` is True, the absolute value of the duration delta is used. This prevents negative - values in the case that `date_to` is in the past relative to `date_from`. """ if not date_to: return None @@ -199,10 +195,7 @@ def format_infraction_with_duration( date_from = date_from or datetime.datetime.now(datetime.timezone.utc) date_to = dateutil.parser.isoparse(date_to).replace(microsecond=0) - delta = relativedelta(date_to, date_from) - if absolute: - delta = abs(delta) - + delta = abs(relativedelta(date_to, date_from)) duration = humanize_delta(delta, max_units=max_units) duration_formatted = f" ({duration})" if duration else "" |