Skip to content

Commit 899ec56

Browse files
committed
unit, utcoffset, utctimetuple
1 parent 0fadaa9 commit 899ec56

File tree

3 files changed

+80
-5
lines changed

3 files changed

+80
-5
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
221221
-i "pandas.Timestamp.today SA01" \
222222
-i "pandas.Timestamp.toordinal SA01" \
223223
-i "pandas.Timestamp.tzinfo GL08" \
224-
-i "pandas.Timestamp.unit SA01" \
225-
-i "pandas.Timestamp.utcoffset SA01" \
226-
-i "pandas.Timestamp.utctimetuple SA01" \
227224
-i "pandas.Timestamp.value GL08" \
228225
-i "pandas.Timestamp.year GL08" \
229226
-i "pandas.api.extensions.ExtensionArray._pad_or_backfill PR01,RT03,SA01" \

pandas/_libs/tslibs/nattype.pyx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,23 @@ class NaTType(_NaT):
595595
utctimetuple = _make_error_func(
596596
"utctimetuple",
597597
"""
598-
Return UTC time tuple, compatible with time.localtime().
598+
Return UTC time tuple, compatible with `time.localtime()`.
599+
600+
This method converts the Timestamp to UTC and returns a time tuple
601+
containing 9 components: year, month, day, hour, minute, second,
602+
weekday, day of year, and DST flag. This is particularly useful for
603+
converting a Timestamp to a format compatible with time module functions.
604+
605+
Returns
606+
-------
607+
time.struct_time
608+
A time.struct_time object representing the UTC time.
609+
610+
See Also
611+
--------
612+
datetime.datetime.utctimetuple : Return UTC time tuple, compatible with time.localtime().
613+
Timestamp.timetuple : Return time tuple of local time.
614+
time.struct_time : Time tuple structure used by time functions.
599615
600616
Examples
601617
--------
@@ -612,6 +628,21 @@ class NaTType(_NaT):
612628
"""
613629
Return utc offset.
614630
631+
This method returns the difference between UTC and the local time
632+
as a `timedelta` object. It is useful for understanding the time
633+
difference between the current timezone and UTC.
634+
635+
Returns
636+
--------
637+
timedelta
638+
The difference between UTC and the local time as a `timedelta` object.
639+
640+
See Also
641+
--------
642+
datetime.datetime.utcoffset : Standard library method to get the UTC offset of a datetime object.
643+
Timestamp.tzname : Return the name of the timezone.
644+
Timestamp.dst : Return the daylight saving time (DST) adjustment.
645+
615646
Examples
616647
--------
617648
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,22 @@ cdef class _Timestamp(ABCTimestamp):
254254
"""
255255
The abbreviation associated with self._creso.
256256

257+
This property returns a string representing the time unit of the Timestamp's
258+
resolution. It corresponds to the smallest time unit that can be represented
259+
by this Timestamp object. The possible values are 's' (second), 'ms' (millisecond),
260+
'us' (microsecond), and 'ns' (nanosecond).
261+
262+
Returns
263+
-------
264+
str
265+
A string abbreviation of the Timestamp's resolution unit:
266+
's' for second, 'ms' for millisecond, 'us' for microsecond, or 'ns' for nanosecond.
267+
268+
See Also
269+
--------
270+
Timestamp.resolution : Return resolution of the Timestamp.
271+
Timedelta : A duration expressing the difference between two dates or times.
272+
257273
Examples
258274
--------
259275
>>> pd.Timestamp("2020-01-01 12:34:56").unit
@@ -1771,6 +1787,21 @@ class Timestamp(_Timestamp):
17711787
"""
17721788
Return utc offset.
17731789
1790+
This method returns the difference between UTC and the local time
1791+
as a `timedelta` object. It is useful for understanding the time
1792+
difference between the current timezone and UTC.
1793+
1794+
Returns
1795+
--------
1796+
timedelta
1797+
The difference between UTC and the local time as a `timedelta` object.
1798+
1799+
See Also
1800+
--------
1801+
datetime.datetime.utcoffset : Standard library method to get the UTC offset of a datetime object.
1802+
Timestamp.tzname : Return the name of the timezone.
1803+
Timestamp.dst : Return the daylight saving time (DST) adjustment.
1804+
17741805
Examples
17751806
--------
17761807
>>> ts = pd.Timestamp('2023-01-01 10:00:00', tz='Europe/Brussels')
@@ -1783,7 +1814,23 @@ class Timestamp(_Timestamp):
17831814

17841815
def utctimetuple(self):
17851816
"""
1786-
Return UTC time tuple, compatible with time.localtime().
1817+
Return UTC time tuple, compatible with `time.localtime()`.
1818+
1819+
This method converts the Timestamp to UTC and returns a time tuple
1820+
containing 9 components: year, month, day, hour, minute, second,
1821+
weekday, day of year, and DST flag. This is particularly useful for
1822+
converting a Timestamp to a format compatible with time module functions.
1823+
1824+
Returns
1825+
-------
1826+
time.struct_time
1827+
A time.struct_time object representing the UTC time.
1828+
1829+
See Also
1830+
--------
1831+
datetime.datetime.utctimetuple : Return UTC time tuple, compatible with time.localtime().
1832+
Timestamp.timetuple : Return time tuple of local time.
1833+
time.struct_time : Time tuple structure used by time functions.
17871834
17881835
Examples
17891836
--------

0 commit comments

Comments
 (0)