René's URL Explorer Experiment


Title: Carry the UTC shift into the date in the Rust precise_diff by ybai08 · Pull Request #1060 · python-pendulum/pendulum · GitHub

Open Graph Title: Carry the UTC shift into the date in the Rust precise_diff by ybai08 · Pull Request #1060 · python-pendulum/pendulum

X Title: Carry the UTC shift into the date in the Rust precise_diff by ybai08 · Pull Request #1060 · python-pendulum/pendulum

Description: Pull Request Check List Added tests for changed code. Updated documentation for changed code. (no documented behaviour changes) When the two datetimes are in different time zones (or fall on the same day), the Rust precise_diff moves each one to UTC by adjusting the hour, minute and second fields by hand. That adjustment only carries when a field goes strictly past 60 or 24, and it never carries into the month or year. So: a time that lands exactly on 24:00 stays as hour 24, a day pushed past either end of the month becomes day 0 or day 32. The pure-Python precise_diff subtracts the offset with datetime arithmetic and does not have this problem, so the results depend on whether the extension is loaded: import pendulum a = pendulum.datetime(2024, 6, 1, tz="UTC") b = pendulum.datetime(2024, 6, 1, 20, tz="America/New_York") # 2024-06-02 00:00 UTC a.diff(b).in_words() # extension: '24 hours' (diff.days == 1, diff.hours == 24) # pure Python: '1 day' a = pendulum.datetime(2023, 6, 1, tz="UTC") b = pendulum.datetime(2023, 12, 31, 20, tz="America/New_York") # 2024-01-01 01:00 UTC a.diff(b).in_words() # extension: '6 months 4 weeks 3 days 1 hour' # pure Python: '7 months 1 hour' a = pendulum.datetime(2024, 1, 30, tz="UTC") b = pendulum.datetime(2024, 3, 1, 5, tz="Asia/Tokyo") # 2024-02-29 20:00 UTC a.diff(b).in_words() # extension: '1 month 20 hours' # pure Python: '4 weeks 2 days 20 hours' This change does the shift on the total seconds of the day and carries any day change into the day, month and year. Since UTC offsets are always less than a day, the date moves by at most one day. The two hand-written copies (one per datetime) are replaced by one DateTimeInfo::shift_to_utc method. This is separate from #901 / #906. The example in #901 comes from is_exact_type_of on the second argument, which #953 changes. The new test uses stdlib datetime objects with zoneinfo, so it does not depend on that change. Testing New test test_precise_diff_timezone_crossing_a_date_boundary in tests/test_helpers.py. It covers the three cases above, in both argument orders. Before the fix, with the extension: 1 failed, 18 passed (assert 0 == 1, PreciseDiff(... days=0, hours=24 ...)). With PENDULUM_EXTENSIONS=0, before and after: 19 passed. After the fix, with the extension: 19 passed. pytest -q tests with the extension: 1871 passed, 3 skipped. With PENDULUM_EXTENSIONS=0: 1871 passed, 3 skipped. A random comparison of pendulum._pendulum.precise_diff against pendulum._helpers.precise_diff. It used 200k pairs per seed and three seeds, with stdlib aware, naive and date inputs over UTC, New York, Paris, Kolkata, Lord Howe, St Johns, Kathmandu and Chatham. Before: 59 mismatches for seed 1. After: 0 mismatches for every seed. cargo fmt --all -- --check and cargo clippy --tests -- -D warnings are clean, and so are ruff check and ruff format --check (0.14.11) on the test file. Not run: mypy, PyPy, the codspeed benchmarks, and other platforms (macOS arm64, CPython 3.13 only). Note: this changes the diff() / Interval results that the extension returns for datetimes in different time zones (or on the same day) when the UTC shift crosses a date boundary. They now match the pure-Python results.

Open Graph Description: Pull Request Check List Added tests for changed code. Updated documentation for changed code. (no documented behaviour changes) When the two datetimes are in different time zones (or fall on th...

X Description: Pull Request Check List Added tests for changed code. Updated documentation for changed code. (no documented behaviour changes) When the two datetimes are in different time zones (or fall on th...

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

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:2bfec845-3575-efd9-7d3b-c9f9a1d12625
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE376:34BF4C:6D7BC9:94E8D5:6B04CD77
html-safe-nonce6b2e44e9c1187acae715b6640dd2cf52b9add617735b0eb581384be4346038c8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzc2OjM0QkY0Qzo2RDdCQzk6OTRFOEQ1OjZCMDRDRDc3IiwidmlzaXRvcl9pZCI6IjQ0NDc5MzYyMjU5NDQ1ODc2MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac29d131355df9b6321d630e6cdf25a4490bb7d2cfcaed7f7501ba50286fb85f1b
hovercard-subject-tagpull_request:4913778461
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/1060/files
twitter:imagehttps://avatars.githubusercontent.com/u/271969568?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/271969568?s=400&v=4
og:image:altPull Request Check List Added tests for changed code. Updated documentation for changed code. (no documented behaviour changes) When the two datetimes are in different time zones (or fall on th...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None27ed421e5c2dac040a37529b5b9191edcc4a3de70521471e81fb4b4d9dc2aa7d
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
release63dc19014c621c67306d7899c04c78dcd0d95803
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-pendulum/pendulum/pull/1060/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-pendulum%2Fpendulum%2Fpull%2F1060%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%2F1060%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/1060/files
Reloadhttps://github.com/python-pendulum/pendulum/pull/1060/files
Reloadhttps://github.com/python-pendulum/pendulum/pull/1060/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
ybai08https://github.com/ybai08
python-pendulum:masterhttps://github.com/python-pendulum/pendulum/tree/master
ybai08:fix-rust-precise-diff-utc-rolloverhttps://github.com/ybai08/pendulum/tree/fix-rust-precise-diff-utc-rollover
Conversation 0 https://github.com/python-pendulum/pendulum/pull/1060
Commits 1 https://github.com/python-pendulum/pendulum/pull/1060/commits
Checks 0 https://github.com/python-pendulum/pendulum/pull/1060/checks
Files changed https://github.com/python-pendulum/pendulum/pull/1060/files
Please reload this pagehttps://github.com/python-pendulum/pendulum/pull/1060/files
Carry the UTC shift into the date in the Rust precise_diff https://github.com/python-pendulum/pendulum/pull/1060/files#top
Show all changes 1 commit https://github.com/python-pendulum/pendulum/pull/1060/files
f7c4a44 Carry the UTC shift into the date in the Rust precise_diff ybai08 Oct 18, 2026 https://github.com/python-pendulum/pendulum/pull/1060/commits/f7c4a442862aa379d33a67b52f1c5da4037869c1
Clear filters https://github.com/python-pendulum/pendulum/pull/1060/files
Please reload this pagehttps://github.com/python-pendulum/pendulum/pull/1060/files
Please reload this pagehttps://github.com/python-pendulum/pendulum/pull/1060/files
helpers.rs https://github.com/python-pendulum/pendulum/pull/1060/files#diff-ae49215e00c412d1aae2c37e2ec302b58314c990c63d5ff1e66927d99b063422
test_helpers.py https://github.com/python-pendulum/pendulum/pull/1060/files#diff-08a6944653efc734f4c8cb856fc854b9f21d655ca69796af2b170c53bff7919e
rust/src/python/helpers.rshttps://github.com/python-pendulum/pendulum/pull/1060/files#diff-ae49215e00c412d1aae2c37e2ec302b58314c990c63d5ff1e66927d99b063422
View file https://github.com/python-pendulum/pendulum/blob/f7c4a442862aa379d33a67b52f1c5da4037869c1/rust/src/python/helpers.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-pendulum/pendulum/pull/1060/{{ revealButtonHref }}
https://github.com/python-pendulum/pendulum/pull/1060/files#diff-ae49215e00c412d1aae2c37e2ec302b58314c990c63d5ff1e66927d99b063422
https://github.com/python-pendulum/pendulum/pull/1060/files#diff-ae49215e00c412d1aae2c37e2ec302b58314c990c63d5ff1e66927d99b063422
https://github.com/python-pendulum/pendulum/pull/1060/files#diff-ae49215e00c412d1aae2c37e2ec302b58314c990c63d5ff1e66927d99b063422
https://github.com/python-pendulum/pendulum/pull/1060/files#diff-ae49215e00c412d1aae2c37e2ec302b58314c990c63d5ff1e66927d99b063422
https://github.com/python-pendulum/pendulum/pull/1060/files#diff-ae49215e00c412d1aae2c37e2ec302b58314c990c63d5ff1e66927d99b063422
tests/test_helpers.pyhttps://github.com/python-pendulum/pendulum/pull/1060/files#diff-08a6944653efc734f4c8cb856fc854b9f21d655ca69796af2b170c53bff7919e
View file https://github.com/python-pendulum/pendulum/blob/f7c4a442862aa379d33a67b52f1c5da4037869c1/tests/test_helpers.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python-pendulum/pendulum/pull/1060/{{ revealButtonHref }}
https://github.com/python-pendulum/pendulum/pull/1060/files#diff-08a6944653efc734f4c8cb856fc854b9f21d655ca69796af2b170c53bff7919e
https://github.com/python-pendulum/pendulum/pull/1060/files#diff-08a6944653efc734f4c8cb856fc854b9f21d655ca69796af2b170c53bff7919e
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.