@@ -161,8 +161,8 @@ cdef _Timestamp create_timestamp_from_ts(
161161 dts.sec, dts.us, tz, fold = fold)
162162
163163 ts_base._value = value
164- ts_base.year = dts.year
165- ts_base.nanosecond = dts.ps // 1000
164+ ts_base._year = dts.year
165+ ts_base._nanosecond = dts.ps // 1000
166166 ts_base._creso = reso
167167
168168 return ts_base
@@ -355,9 +355,9 @@ cdef class _Timestamp(ABCTimestamp):
355355 # -----------------------------------------------------------------
356356
357357 def __hash__ (_Timestamp self ):
358- if self .nanosecond :
358+ if self ._nanosecond :
359359 return hash (self ._value)
360- if not (1 <= self .year <= 9999 ):
360+ if not (1 <= self ._year <= 9999 ):
361361 # out of bounds for pydatetime
362362 return hash (self ._value)
363363 if self .fold:
@@ -375,7 +375,7 @@ cdef class _Timestamp(ABCTimestamp):
375375 elif cnp.is_datetime64_object(other):
376376 ots = Timestamp(other)
377377 elif PyDateTime_Check(other):
378- if self .nanosecond == 0 :
378+ if self ._nanosecond == 0 :
379379 val = self .to_pydatetime()
380380 return PyObject_RichCompareBool(val, other, op)
381381
@@ -454,7 +454,7 @@ cdef class _Timestamp(ABCTimestamp):
454454 if not self ._can_compare(other):
455455 return NotImplemented
456456
457- if self .nanosecond == 0 :
457+ if self ._nanosecond == 0 :
458458 return PyObject_RichCompareBool(dtval, other, op)
459459
460460 # otherwise we have dtval < self
@@ -463,9 +463,9 @@ cdef class _Timestamp(ABCTimestamp):
463463 if op == Py_EQ:
464464 return False
465465 if op == Py_LE or op == Py_LT:
466- return self .year <= other.year
466+ return self ._year <= other.year
467467 if op == Py_GE or op == Py_GT:
468- return self .year >= other.year
468+ return self ._year >= other.year
469469
470470 cdef bint _can_compare(self , datetime other):
471471 if self .tzinfo is not None :
@@ -606,7 +606,7 @@ cdef class _Timestamp(ABCTimestamp):
606606
607607 if own_tz is not None and not is_utc(own_tz):
608608 pydatetime_to_dtstruct(self , & dts)
609- val = npy_datetimestruct_to_datetime(self ._creso, & dts) + self .nanosecond
609+ val = npy_datetimestruct_to_datetime(self ._creso, & dts) + self ._nanosecond
610610 else :
611611 val = self ._value
612612 return val
@@ -898,7 +898,7 @@ cdef class _Timestamp(ABCTimestamp):
898898 >>> ts.is_leap_year
899899 True
900900 """
901- return bool(ccalendar.is_leapyear(self.year ))
901+ return bool(ccalendar.is_leapyear(self._year ))
902902
903903 @property
904904 def day_of_week(self) -> int:
@@ -942,7 +942,7 @@ cdef class _Timestamp(ABCTimestamp):
942942 >>> ts.day_of_year
943943 74
944944 """
945- return ccalendar.get_day_of_year(self.year , self.month, self.day)
945+ return ccalendar.get_day_of_year(self._year , self.month, self.day)
946946
947947 @property
948948 def quarter(self) -> int:
@@ -1050,7 +1050,7 @@ cdef class _Timestamp(ABCTimestamp):
10501050 >>> ts.year
10511051 2024
10521052 """
1053- return super().year
1053+ return self._year
10541054
10551055 @property
10561056 def month(self) -> int:
@@ -1188,7 +1188,7 @@ cdef class _Timestamp(ABCTimestamp):
11881188 >>> ts.nanosecond
11891189 15
11901190 """
1191- return super().nanosecond
1191+ return self._nanosecond
11921192
11931193 @property
11941194 def week(self) -> int:
@@ -1210,7 +1210,7 @@ cdef class _Timestamp(ABCTimestamp):
12101210 >>> ts.week
12111211 11
12121212 """
1213- return ccalendar.get_week_of_year(self.year , self.month, self.day)
1213+ return ccalendar.get_week_of_year(self._year , self.month, self.day)
12141214
12151215 @property
12161216 def days_in_month(self) -> int:
@@ -1232,7 +1232,7 @@ cdef class _Timestamp(ABCTimestamp):
12321232 >>> ts.days_in_month
12331233 31
12341234 """
1235- return ccalendar.get_days_in_month(self.year , self.month)
1235+ return ccalendar.get_days_in_month(self._year , self.month)
12361236
12371237 # -----------------------------------------------------------------
12381238 # Transformation Methods
@@ -1306,7 +1306,7 @@ cdef class _Timestamp(ABCTimestamp):
13061306
13071307 The full format looks like ' YYYY-MM-DD HH:MM:SS.mmmmmmnnn' .
13081308 By default, the fractional part is omitted if self .microsecond == 0
1309- and self .nanosecond == 0.
1309+ and self ._nanosecond == 0.
13101310
13111311 If self .tzinfo is not None , the UTC offset is also attached, giving
13121312 giving a full format of ' YYYY-MM-DD HH:MM:SS.mmmmmmnnn+HH:MM' .
@@ -1342,21 +1342,21 @@ cdef class _Timestamp(ABCTimestamp):
13421342 base_ts = "microseconds" if timespec == "nanoseconds" else timespec
13431343 base = super(_Timestamp, self).isoformat(sep=sep, timespec=base_ts)
13441344 # We need to replace the fake year 1970 with our real year
1345- base = f"{self.year :04d}-" + base.split("-", 1)[1]
1345+ base = f"{self._year :04d}-" + base.split("-", 1)[1]
13461346
1347- if self.nanosecond == 0 and timespec != "nanoseconds":
1347+ if self._nanosecond == 0 and timespec != "nanoseconds":
13481348 return base
13491349
13501350 if self.tzinfo is not None:
13511351 base1, base2 = base[:-6], base[-6:]
13521352 else:
13531353 base1, base2 = base, ""
13541354
1355- if timespec == "nanoseconds" or (timespec == "auto" and self.nanosecond ):
1355+ if timespec == "nanoseconds" or (timespec == "auto" and self._nanosecond ):
13561356 if self.microsecond or timespec == "nanoseconds":
1357- base1 += f"{self.nanosecond :03d}"
1357+ base1 += f"{self._nanosecond :03d}"
13581358 else:
1359- base1 += f".{self.nanosecond :09d}"
1359+ base1 += f".{self._nanosecond :09d}"
13601360
13611361 return base1 + base2
13621362
@@ -1390,14 +1390,14 @@ cdef class _Timestamp(ABCTimestamp):
13901390 def _date_repr(self) -> str:
13911391 # Ideal here would be self.strftime("%Y -%m -%d "), but
13921392 # the datetime strftime() methods require year >= 1900 and is slower
1393- return f"{self.year }-{self.month:02d}-{self.day:02d}"
1393+ return f"{self._year }-{self.month:02d}-{self.day:02d}"
13941394
13951395 @property
13961396 def _time_repr(self) -> str:
13971397 result = f"{self.hour:02d}:{self.minute:02d}:{self.second:02d}"
13981398
1399- if self.nanosecond != 0:
1400- result += f".{self.nanosecond + 1000 * self.microsecond:09d}"
1399+ if self._nanosecond != 0:
1400+ result += f".{self._nanosecond + 1000 * self.microsecond:09d}"
14011401 elif self.microsecond != 0:
14021402 result += f".{self.microsecond:06d}"
14031403
@@ -1561,11 +1561,11 @@ cdef class _Timestamp(ABCTimestamp):
15611561 >>> pd.NaT.to_pydatetime()
15621562 NaT
15631563 """
1564- if self.nanosecond != 0 and warn:
1564+ if self._nanosecond != 0 and warn:
15651565 warnings.warn("Discarding nonzero nanoseconds in conversion.",
15661566 UserWarning, stacklevel=find_stack_level())
15671567
1568- return datetime(self.year , self.month, self.day,
1568+ return datetime(self._year , self.month, self.day,
15691569 self.hour, self.minute, self.second,
15701570 self.microsecond, self.tzinfo, fold=self.fold)
15711571
@@ -2044,7 +2044,7 @@ class Timestamp(_Timestamp):
20442044 ' 2020-03-14 15:32:52'
20452045 """
20462046 try:
2047- _dt = datetime(self.year , self.month, self.day,
2047+ _dt = datetime(self._year , self.month, self.day,
20482048 self.hour, self.minute, self.second,
20492049 self.microsecond, self.tzinfo, fold=self.fold)
20502050 except ValueError as err:
@@ -2087,7 +2087,7 @@ class Timestamp(_Timestamp):
20872087 ' Sun Jan 1 10:00:00 2023'
20882088 """
20892089 try:
2090- _dt = datetime(self.year , self.month, self.day,
2090+ _dt = datetime(self._year , self.month, self.day,
20912091 self.hour, self.minute, self.second,
20922092 self.microsecond, self.tzinfo, fold=self.fold)
20932093 except ValueError as err:
@@ -2127,7 +2127,7 @@ class Timestamp(_Timestamp):
21272127 datetime.date(2023 , 1 , 1 )
21282128 """
21292129 try:
2130- _dt = dt.date(self.year , self.month, self.day)
2130+ _dt = dt.date(self._year , self.month, self.day)
21312131 except ValueError as err:
21322132 raise NotImplementedError(
21332133 "date not yet supported on Timestamps which "
@@ -2176,7 +2176,7 @@ class Timestamp(_Timestamp):
21762176 datetime.IsoCalendarDate(year = 2022 , week = 52 , weekday = 7 )
21772177 """
21782178 try:
2179- _dt = datetime(self.year , self.month, self.day,
2179+ _dt = datetime(self._year , self.month, self.day,
21802180 self.hour, self.minute, self.second,
21812181 self.microsecond, self.tzinfo, fold=self.fold)
21822182 except ValueError as err:
@@ -2318,7 +2318,7 @@ class Timestamp(_Timestamp):
23182318 tm_hour = 10 , tm_min = 0 , tm_sec = 0 , tm_wday = 6 , tm_yday = 1 , tm_isdst = - 1 )
23192319 """
23202320 try:
2321- _dt = datetime(self.year , self.month, self.day,
2321+ _dt = datetime(self._year , self.month, self.day,
23222322 self.hour, self.minute, self.second,
23232323 self.microsecond, self.tzinfo, fold=self.fold)
23242324 except ValueError as err:
@@ -2379,7 +2379,7 @@ class Timestamp(_Timestamp):
23792379 738521
23802380 """
23812381 try:
2382- _dt = datetime(self.year , self.month, self.day,
2382+ _dt = datetime(self._year , self.month, self.day,
23832383 self.hour, self.minute, self.second,
23842384 self.microsecond, self.tzinfo, fold=self.fold)
23852385 except ValueError as err:
@@ -3268,7 +3268,7 @@ default 'raise'
32683268
32693269 # setup components
32703270 pandas_datetime_to_datetimestruct(value, self._creso, &dts)
3271- dts.ps = self.nanosecond * 1000
3271+ dts.ps = self._nanosecond * 1000
32723272
32733273 # replace
32743274 def validate(k, v):
@@ -3358,7 +3358,7 @@ default 'raise'
33583358 >>> ts.to_julian_date()
33593359 2458923.147824074
33603360 """
3361- year = self.year
3361+ year = self._year
33623362 month = self.month
33633363 day = self.day
33643364 if month <= 2:
@@ -3375,7 +3375,7 @@ default 'raise'
33753375 self.minute / 60.0 +
33763376 self.second / 3600.0 +
33773377 self.microsecond / 3600.0 / 1e+6 +
3378- self.nanosecond / 3600.0 / 1e+9
3378+ self._nanosecond / 3600.0 / 1e+9
33793379 ) / 24.0)
33803380
33813381 def isoweekday(self):
@@ -3426,7 +3426,7 @@ default 'raise'
34263426 """
34273427 # same as super().weekday(), but that breaks because of how
34283428 # we have overridden year, see note in create_timestamp_from_ts
3429- return ccalendar.dayofweek(self.year , self.month, self.day)
3429+ return ccalendar.dayofweek(self._year , self.month, self.day)
34303430
34313431
34323432# Aliases
0 commit comments