René's URL Explorer Experiment


Title: fix: preserve microsecond precision in Time differences and selection by mkantautas · Pull Request #1069 · python-pendulum/pendulum · GitHub

Open Graph Title: fix: preserve microsecond precision in Time differences and selection by mkantautas · Pull Request #1069 · python-pendulum/pendulum

X Title: fix: preserve microsecond precision in Time differences and selection by mkantautas · Pull Request #1069 · python-pendulum/pendulum

Description: Fixes #584. Time.diff() built both totals from hours, minutes and seconds only, so both operands' microseconds were dropped. For example, Time(12, 0, 0, 500000).diff(Time(12, 0, 1)) returned 1 second instead of 0.5. Time - Time uses diff() and had the same error. This adds the microseconds to both totals. closest() and farthest() compared diff(...).in_seconds(), which truncates to whole seconds. Before this change they could pick the wrong candidate when sub-second parts mattered. For example, Time(12, 0, 0, 900000).closest(Time(12, 0, 1), Time(12, 0, 0)) returned 12:00:00, which is 0.9 seconds away, instead of 12:00:01, which is 0.1 seconds away. With precise differences, truncation would also turn distinct sub-second distances into ties. They now compare total_seconds(), in line with DateTime.closest() and DateTime.farthest(), which already compare full-precision distances. Equal distances still return the second candidate. Tests: tests/time/test_diff.py and tests/time/test_sub.py cover differences within and across seconds, signed results, the minimum and maximum times, and standard-library time operands. tests/time/test_comparison.py covers closest() and farthest() with sub-second distances, both candidate orders and standard-library time candidates. Six existing diff_for_humans() tests now freeze the clock, matching the equivalent DateTime tests. With microsecond precision, a future comparison against a ticking clock can fall just short of a minute or an hour and show the preceding unit, as DateTime already does. Validation: Without the fix, the six new difference and subtraction tests fail (65 passed, 6 failed). All results below come from one run with Python 3.13 on Linux and python-dateutil 3.0.0. On master (e06dace), two of the six new comparison tests fail: the cross-second closest() and farthest() cases (24 passed, 2 failed). With the fix, tests/time/test_diff.py, tests/time/test_sub.py and tests/time/test_comparison.py give 97 passed with the pure-Python backend. With the compiled extension, they also give 97 passed; that run used the extension module from the pendulum 3.3.0 wheel, since this change touches no Rust code. Ruff 0.14.11 check and format: clean. Full suite with the pure-Python backend: 1,882 passed, 3 skipped, 1 failed. The failure is tests/test_main.py::test_instance_with_aware_datetime_any_tzinfo, which expects +02:00 and gets Europe/Paris. It fails the same way on unchanged master with the same dependencies. Pull Request Check List Added tests for changed code. Updated documentation for changed code. Not updated: this restores microsecond precision and adds no API.

Open Graph Description: Fixes #584. Time.diff() built both totals from hours, minutes and seconds only, so both operands' microseconds were dropped. For example, Time(12, 0, 0, 500000).diff(Time(12, 0, 1)) returned 1 ...

X Description: Fixes #584. Time.diff() built both totals from hours, minutes and seconds only, so both operands' microseconds were dropped. For example, Time(12, 0, 0, 500000).diff(Time(12, 0, 1)) returne...

Opengraph URL: https://github.com/python-pendulum/pendulum/pull/1069

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.4

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:93275190-d8c4-24f5-1a7f-4706bea964af
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8E26:133E28:F34C5:156719:6B046492
html-safe-nonce97d35320f677a41e232ba6755ba04d8194ccdb3ad002cc4651d861f91ed0dd21
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTI2OjEzM0UyODpGMzRDNToxNTY3MTk6NkIwNDY0OTIiLCJ2aXNpdG9yX2lkIjoiNTEyNTkwNjMzNTU2MDY1NjAxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac2967b6e3785e0e2bae499adda368e4d498379c10fda7e24a4e1a85b453dbc714
hovercard-subject-tagpull_request:5007303512
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python-pendulum/pendulum/pull/1069/files
twitter:imagehttps://avatars.githubusercontent.com/u/19753711?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/19753711?s=400&v=4
og:image:altFixes #584. Time.diff() built both totals from hours, minutes and seconds only, so both operands' microseconds were dropped. For example, Time(12, 0, 0, 500000).diff(Time(12, 0, 1)) returned 1 ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None2d58451b4bcb73c33c67bfb6b28fb75fe6d5e279daf9b560fa4fd832f3d8c9a6
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python-pendulum/pendulum git https://github.com/python-pendulum/pendulum.git
octolytics-dimension-user_id191041900
octolytics-dimension-user_loginpython-pendulum
octolytics-dimension-repository_id62095504
octolytics-dimension-repository_nwopython-pendulum/pendulum
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id62095504
octolytics-dimension-repository_network_root_nwopython-pendulum/pendulum
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release03e114520787ad27289207f153520ef97461127c
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-pendulum/pendulum/pull/1069/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-pendulum%2Fpendulum%2Fpull%2F1069%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-pendulum%2Fpendulum%2Fpull%2F1069%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python-pendulum%2Fpendulum
Reloadhttps://github.com/python-pendulum/pendulum/pull/1069/files
Reloadhttps://github.com/python-pendulum/pendulum/pull/1069/files
Reloadhttps://github.com/python-pendulum/pendulum/pull/1069/files
python-pendulumhttps://github.com/python-pendulum
pendulumhttps://github.com/python-pendulum/pendulum
Codehttps://github.com/python-pendulum/pendulum
Issues211 (211)https://github.com/python-pendulum/pendulum/issues
Pull requests96 (96)https://github.com/python-pendulum/pendulum/pulls
Discussionshttps://github.com/python-pendulum/pendulum/discussions
Actionshttps://github.com/python-pendulum/pendulum/actions
Projectshttps://github.com/python-pendulum/pendulum/projects
Security and qualityhttps://github.com/python-pendulum/pendulum/security
Insightshttps://github.com/python-pendulum/pendulum/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpython-pendulum%2Fpendulum%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython-pendulum%2Fpendulum%2Fissues%2Fnew%2Fchoose
mkantautashttps://github.com/mkantautas
python-pendulum:masterhttps://github.com/python-pendulum/pendulum/tree/master
mkantautas:fix/time-diff-microseconds-584-r2https://github.com/mkantautas/pendulum/tree/fix/time-diff-microseconds-584-r2
Conversation 0 https://github.com/python-pendulum/pendulum/pull/1069
Commits 2 https://github.com/python-pendulum/pendulum/pull/1069/commits
Checks 0 https://github.com/python-pendulum/pendulum/pull/1069/checks
Files changed https://github.com/python-pendulum/pendulum/pull/1069/files
Please reload this pagehttps://github.com/python-pendulum/pendulum/pull/1069/files
fix: preserve microsecond precision in Time differences and selection https://github.com/python-pendulum/pendulum/pull/1069/files#top
Show all changes 2 commits https://github.com/python-pendulum/pendulum/pull/1069/files
7a2fb2a fix: preserve microseconds in Time differences mkantautas Oct 25, 2026 https://github.com/python-pendulum/pendulum/pull/1069/commits/7a2fb2af7cf240b792a8f082c2cfdc97eac2d047
109fcae fix: compare precise distances in Time selection mkantautas Oct 25, 2026 https://github.com/python-pendulum/pendulum/pull/1069/commits/109fcae9f4014cb737ad51c80204bbbd456761ae
Clear filters https://github.com/python-pendulum/pendulum/pull/1069/files
Please reload this pagehttps://github.com/python-pendulum/pendulum/pull/1069/files
Please reload this pagehttps://github.com/python-pendulum/pendulum/pull/1069/files
time.py https://github.com/python-pendulum/pendulum/pull/1069/files#diff-ac29355b335ea17a8f79b610f9aded69fa8ba3759760dee3081eedba71c7005f
test_comparison.py https://github.com/python-pendulum/pendulum/pull/1069/files#diff-50f0b5405002605a80bb2e4fa73a88f5fe56047540dba6bf7040398948b5acb8
test_diff.py https://github.com/python-pendulum/pendulum/pull/1069/files#diff-c800dad410072247721f9af2992d8a826df887835ba2c6f36b87f498782dec3e
test_sub.py https://github.com/python-pendulum/pendulum/pull/1069/files#diff-6adfd30ed011b31414451de57c9790ac862b5f3973b58d3d551efa4ff5e0047b
src/pendulum/time.pyhttps://github.com/python-pendulum/pendulum/pull/1069/files#diff-ac29355b335ea17a8f79b610f9aded69fa8ba3759760dee3081eedba71c7005f
View file https://github.com/python-pendulum/pendulum/blob/109fcae9f4014cb737ad51c80204bbbd456761ae/src/pendulum/time.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-pendulum/pendulum/pull/1069/{{ revealButtonHref }}
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-ac29355b335ea17a8f79b610f9aded69fa8ba3759760dee3081eedba71c7005f
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-ac29355b335ea17a8f79b610f9aded69fa8ba3759760dee3081eedba71c7005f
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-ac29355b335ea17a8f79b610f9aded69fa8ba3759760dee3081eedba71c7005f
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-ac29355b335ea17a8f79b610f9aded69fa8ba3759760dee3081eedba71c7005f
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-ac29355b335ea17a8f79b610f9aded69fa8ba3759760dee3081eedba71c7005f
tests/time/test_comparison.pyhttps://github.com/python-pendulum/pendulum/pull/1069/files#diff-50f0b5405002605a80bb2e4fa73a88f5fe56047540dba6bf7040398948b5acb8
View file https://github.com/python-pendulum/pendulum/blob/109fcae9f4014cb737ad51c80204bbbd456761ae/tests/time/test_comparison.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-pendulum/pendulum/pull/1069/{{ revealButtonHref }}
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-50f0b5405002605a80bb2e4fa73a88f5fe56047540dba6bf7040398948b5acb8
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-50f0b5405002605a80bb2e4fa73a88f5fe56047540dba6bf7040398948b5acb8
tests/time/test_diff.pyhttps://github.com/python-pendulum/pendulum/pull/1069/files#diff-c800dad410072247721f9af2992d8a826df887835ba2c6f36b87f498782dec3e
View file https://github.com/python-pendulum/pendulum/blob/109fcae9f4014cb737ad51c80204bbbd456761ae/tests/time/test_diff.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-pendulum/pendulum/pull/1069/{{ revealButtonHref }}
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-c800dad410072247721f9af2992d8a826df887835ba2c6f36b87f498782dec3e
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-c800dad410072247721f9af2992d8a826df887835ba2c6f36b87f498782dec3e
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-c800dad410072247721f9af2992d8a826df887835ba2c6f36b87f498782dec3e
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-c800dad410072247721f9af2992d8a826df887835ba2c6f36b87f498782dec3e
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-c800dad410072247721f9af2992d8a826df887835ba2c6f36b87f498782dec3e
tests/time/test_sub.pyhttps://github.com/python-pendulum/pendulum/pull/1069/files#diff-6adfd30ed011b31414451de57c9790ac862b5f3973b58d3d551efa4ff5e0047b
View file https://github.com/python-pendulum/pendulum/blob/109fcae9f4014cb737ad51c80204bbbd456761ae/tests/time/test_sub.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-pendulum/pendulum/pull/1069/{{ revealButtonHref }}
https://github.com/python-pendulum/pendulum/pull/1069/files#diff-6adfd30ed011b31414451de57c9790ac862b5f3973b58d3d551efa4ff5e0047b
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.