Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

handle DST properly #1209 #1211

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

Draft
aurora324 wants to merge 1 commit into arrow-py:master
base: master
Choose a base branch
Loading
from aurora324:master
Draft

Conversation

Copy link

@aurora324 aurora324 commented May 20, 2025

Pull Request Checklist

Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all appropriate boxes:

  • 🧪 Added tests for changed code.
  • 🛠️ All tests pass when run locally (run tox or make test to find out!).
  • 🧹 All linting checks pass when run locally (run tox -e lint or make lint to find out!).
  • 📚 Updated documentation for changed code.
  • ⏩ Code is up-to-date with the master branch.

If you have any questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!

Description of Changes

Bug Fix

  • Fixed the time zone calculation error in the shift() method during DST transitions.
  • Original issue: Performing relativedelta operations directly on localized time caused errors during DST transition points.
  • New solution: Convert times with time zones to UTC for calculations, then convert them back to the original time zone.

Code Changes

# Original code (problematic code)
current = self._datetime + relativedelta(**relative_kwargs)
# Modified code (fixed code)
original_tz = self.tzinfo
if self._datetime.tzinfo is not None:
 utc_dt = self._datetime.astimezone(dateutil_tz.UTC)
 current = utc_dt + relativedelta(**relative_kwargs)
 current = current.astimezone(original_tz)
else:
 current = self._datetime + relativedelta(**relative_kwargs)

)

current = self._datetime + relativedelta(**relative_kwargs)
# current = self._datetime + relativedelta(**relative_kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind adding unit tests for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jadchaar jadchaar jadchaar left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /