|
30 | 30 | from pandas.core.indexes.timedeltas import TimedeltaIndex, timedelta_range
|
31 | 31 |
|
32 | 32 | from pandas.tseries.frequencies import to_offset
|
33 |
| -from pandas.tseries.offsets import ( |
34 |
| - DateOffset, Day, Nano, Tick, delta_to_nanoseconds) |
| 33 | +from pandas.tseries.offsets import DateOffset, Day, Nano, Tick |
35 | 34 |
|
36 | 35 | _shared_docs_kwargs = dict()
|
37 | 36 |
|
@@ -1613,20 +1612,20 @@ def _get_timestamp_range_edges(first, last, offset, closed='left', base=0):
|
1613 | 1612 | A tuple of length 2, containing the adjusted pd.Timestamp objects.
|
1614 | 1613 | """
|
1615 | 1614 | if isinstance(offset, Tick):
|
1616 |
| - is_day = isinstance(offset, Day) |
1617 |
| - day_nanos = delta_to_nanoseconds(timedelta(1)) |
1618 |
| - |
1619 |
| - # #1165 and #24127 |
1620 |
| - if (is_day and not offset.nanos % day_nanos) or not is_day: |
1621 |
| - first, last = _adjust_dates_anchored(first, last, offset, |
1622 |
| - closed=closed, base=base) |
1623 |
| - if is_day and first.tz is not None: |
1624 |
| - # _adjust_dates_anchored assumes 'D' means 24H, but first/last |
1625 |
| - # might contain a DST transition (23H, 24H, or 25H). |
1626 |
| - # Ensure first/last snap to midnight. |
1627 |
| - first = first.normalize() |
1628 |
| - last = last.normalize() |
1629 |
| - return first, last |
| 1615 | + if isinstance(offset, Day): |
| 1616 | + # _adjust_dates_anchored assumes 'D' means 24H, but first/last |
| 1617 | + # might contain a DST transition (23H, 24H, or 25H). |
| 1618 | + # So "pretend" the dates are naive when adjusting the endpoints |
| 1619 | + tz = first.tz |
| 1620 | + first = first.tz_localize(None) |
| 1621 | + last = last.tz_localize(None) |
| 1622 | + |
| 1623 | + first, last = _adjust_dates_anchored(first, last, offset, |
| 1624 | + closed=closed, base=base) |
| 1625 | + if isinstance(offset, Day): |
| 1626 | + first = first.tz_localize(tz) |
| 1627 | + last = last.tz_localize(tz) |
| 1628 | + return first, last |
1630 | 1629 |
|
1631 | 1630 | else:
|
1632 | 1631 | first = first.normalize()
|
|
0 commit comments