-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-132642: Add documentation on how to render human-readable timed 8000 elta object #133825
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
Conversation
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
I just confirmed the code on the doc is working as expected with the local Python(3.11.11). $ python
Python 3.11.11 (main, Mar 29 2025, 18:04:05) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import timedelta
>>> d = timedelta(hours=-1)
>>> str(d)
'-1 day, 23:00:00'
>>> def pretty_timedelta(td):
... if td.days >= 0:
... return str(td)
... return f'-({-td!s})'
...
>>> pretty_timedelta(d)
'-(1:00:00)' |
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
We could make this a doctest? Anything against this @picnixz ? |
We don't need more doctests IMO. The doctest job is already slow IMO. We didn't do doctests for the other code blocks. It's better to test that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (with one minor change)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@picnixz eq(f'-({-td(hours=-1)!s})', "-(1:00:00)") at: cpython/Lib/test/datetimetester.py Lines 755 to 774 in dbca27c
Does that make sense? |
You can add it and add a note saying that it's for the docs recipe. |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Thanks @KentaroJay for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Thanks @KentaroJay for the PR, and @picnixz for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…jects (pythonGH-133825) (cherry picked from commit efcc42b) Co-authored-by: Kentaro Jay Takahashi <64148935+KentaroJay@users.noreply.github.com>
GH-133836 is a backport of this pull request to the 3.13 branch. |
…jects (pythonGH-133825) (cherry picked from commit efcc42b) Co-authored-by: Kentaro Jay Takahashi <64148935+KentaroJay@users.noreply.github.com>
GH-133837 is a backport of this pull request to the 3.14 branch. |
timedelta
in human-readable form #132642📚 Documentation preview 📚: https://cpython-previews--133825.org.readthedocs.build/