Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions arrow/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def shift(self, check_imaginary: bool = True, **kwargs: Any) -> "Arrow":
according to inputs.

Parameters:
check_imaginary (bool): If True (default), will check for and resolve
check_imaginary (bool): If True (default), checks for and resolves
imaginary times (like during DST transitions). If False, skips this check.


Expand Down Expand Up @@ -1048,9 +1048,11 @@ def shift(self, check_imaginary: bool = True, **kwargs: Any) -> "Arrow":

current = self._datetime + relativedelta(**relative_kwargs)

# If check_imaginary is True, perform the check for imaginary times (DST transitions)
if check_imaginary and not dateutil_tz.datetime_exists(current):
current = dateutil_tz.resolve_imaginary(current)
if check_imaginary:
# Check if the resulting datetime exists (not imaginary during DST transition)
if not dateutil_tz.datetime_exists(current):
# Resolve imaginary time by adjusting to the appropriate DST offset
current = dateutil_tz.resolve_imaginary(current)

return self.fromdatetime(current)

Expand Down
Loading