-
Notifications
You must be signed in to change notification settings - Fork 453
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
Multiple units in format_timedelta()
#728
Comments
I'm looking at this in my free time. |
I think there's probably a good recursive solution to this. Here's my fork |
My first crack at the problem can produce some of your desired output. However, it doesn't handle instances where the granularity is before the base case of |
Alright, this commit does everything you asked for. |
^^^ No it definitely does not lol. Still working on my fork. Handling the case where you have granularity of seconds but say, just one week. Aside from that, I think what I have now is a lot better. |
I'm not sure what the original intention is, but for me it would be to simply have it actually spell out all the information we have and be exact with that. That means, if I have a year, one week and 2 minutes, I don't wanna ignore the 2 minutes. |
Right now, With what you said in mind, I guess it would also make sense to allow passing some value ( |
I'd really like this as well, it's often annoying to have bits at or above granularity cut off in "format_timedelta".
I can't say I agree with showing intermediate zero-valued steps by default. Also sadly this is not a backwards-compatible change, so it absolutely needs an additional parameter (or additional granularity values). Especially due to the What I was thinking of is:
If even more complexity / specificity is needed in the precision, it would probably need to be a richer object, possibly the combination of a count and various formatting flags (in which case the "fullest" format might be a precision flag rather than a separate format from "fuller"). |
My requirement is to always show the time as exact as possible, down to the second, but remove empty values. |
IMHO, in practical use the information should be presented in the required and sufficient amount. so there should be two options as @xmo-odoo described:
|
Agree with the previous posts, is there any update on this topic? Added a PR #1066 |
Would it be possible to return more than just one unit for passed
timedelta
object?For example:
Note:
granularity
is already used for something else informat_timedelta()
, so that kwarg would need to be called differently, I just couldn't think of better name.The text was updated successfully, but these errors were encountered: