Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Utils] humanize_timedelta returns empty string for less than a second. #2986

Closed
jack1142 opened this issue Sep 7, 2019 · 1 comment · Fixed by #3000
Closed

[Utils] humanize_timedelta returns empty string for less than a second. #2986

jack1142 opened this issue Sep 7, 2019 · 1 comment · Fixed by #3000

Comments

@jack1142
Copy link
Member

@jack1142 jack1142 commented Sep 7, 2019

Other bugs

What were you trying to do?

Pass 0.5 to seconds argument of humanize_timedelta.

What were you expecting to happen?

I suppose it would make most sense to get string "less than a second", though I'm not sure if that would be good for all contexts (for example - "This command is on cooldown. Try again in less than a second." might not be good).

What actually happened?

I got empty string.

How can we reproduce this issue?

Call humanize_timedelta(seconds=0.5).


Technically typing for humanize_timedelta says it only accepts ints but you can pass timedelta to that function instead and timedelta accepts deltas smaller than a second , so I just decided to base the issue on seconds argument.

@mikeshardmind
Copy link
Contributor

@mikeshardmind mikeshardmind commented Sep 7, 2019

I don't think I'd consider this a bug. We should still clear up the usage to note that it drops fractional seconds, and then allow cog creators to decide independently per their use case if it makes more sense to swap that for "about one second", "less than one second", or something else entirely.

# Using the empty response advantageously
timedelta_str = humanize_timedelta(seconds=some_positive_float) or "less than 1 second"

mikeshardmind added a commit that referenced this issue Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants