Skip to content

Commit 29a8a76

Browse files
author
Matt Roeschke
committed
Replace CalendarDay with Day; remove Day Tick
1 parent 65d2edb commit 29a8a76

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

pandas/tseries/offsets.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
'LastWeekOfMonth', 'FY5253Quarter', 'FY5253',
4242
'Week', 'WeekOfMonth', 'Easter',
4343
'Hour', 'Minute', 'Second', 'Milli', 'Micro', 'Nano',
44-
'DateOffset', 'CalendarDay']
44+
'DateOffset']
4545

4646
# convert to/from datetime/timestamp to allow invalid Timestamp ranges to
4747
# pass thru
@@ -2124,14 +2124,15 @@ def onOffset(self, dt):
21242124
return date(dt.year, dt.month, dt.day) == easter(dt.year)
21252125

21262126

2127-
class CalendarDay(SingleConstructorOffset):
2127+
class Day(SingleConstructorOffset):
21282128
"""
2129-
Calendar day offset. Respects calendar arithmetic as opposed to Day which
2130-
respects absolute time.
2129+
Day offset representing a calendar day. Respects calendar day arithmetic
2130+
in the midst of daylight savings time transitions; therefore, Day does not
2131+
necessarily equate to 24 hours.
21312132
"""
21322133
_adjust_dst = True
21332134
_inc = Timedelta(days=1)
2134-
_prefix = 'CD'
2135+
_prefix = 'D'
21352136
_attributes = frozenset(['n', 'normalize'])
21362137

21372138
def __init__(self, n=1, normalize=False):
@@ -2140,11 +2141,11 @@ def __init__(self, n=1, normalize=False):
21402141
@apply_wraps
21412142
def apply(self, other):
21422143
"""
2143-
Apply scalar arithmetic with CalendarDay offset. Incoming datetime
2144+
Apply scalar arithmetic with Day offset. Incoming datetime
21442145
objects can be tz-aware or naive.
21452146
"""
21462147
if type(other) == type(self):
2147-
# Add other CalendarDays
2148+
# Add other Days
21482149
return type(self)(self.n + other.n, normalize=self.normalize)
21492150
tzinfo = getattr(other, 'tzinfo', None)
21502151
if tzinfo is not None:
@@ -2160,12 +2161,12 @@ def apply(self, other):
21602161
return as_timestamp(other)
21612162
except TypeError:
21622163
raise TypeError("Cannot perform arithmetic between {other} and "
2163-
"CalendarDay".format(other=type(other)))
2164+
"Day".format(other=type(other)))
21642165

21652166
@apply_index_wraps
21662167
def apply_index(self, i):
21672168
"""
2168-
Apply the CalendarDay offset to a DatetimeIndex. Incoming DatetimeIndex
2169+
Apply the Day offset to a DatetimeIndex. Incoming DatetimeIndex
21692170
objects are assumed to be tz_naive
21702171
"""
21712172
return i + self.n * self._inc
@@ -2302,11 +2303,6 @@ def _delta_to_tick(delta):
23022303
return Nano(nanos)
23032304

23042305

2305-
class Day(Tick):
2306-
_inc = Timedelta(days=1)
2307-
_prefix = 'D'
2308-
2309-
23102306
class Hour(Tick):
23112307
_inc = Timedelta(hours=1)
23122308
_prefix = 'H'
@@ -2455,5 +2451,4 @@ def generate_range(start=None, end=None, periods=None,
24552451
WeekOfMonth, # 'WOM'
24562452
FY5253,
24572453
FY5253Quarter,
2458-
CalendarDay # 'CD'
24592454
]}

0 commit comments

Comments
 (0)