Skip to content

Commit dd65104

Browse files
committed
Fixed code styling
1 parent 513e787 commit dd65104

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7878
-i "pandas.Timestamp.max PR02" \
7979
-i "pandas.Timestamp.min PR02" \
8080
-i "pandas.Timestamp.resolution PR02" \
81-
-i "pandas.Timestamp.tzinfo GL08" \
8281
-i "pandas.core.groupby.DataFrameGroupBy.plot PR02" \
8382
-i "pandas.core.groupby.SeriesGroupBy.plot PR02" \
8483
-i "pandas.core.resample.Resampler.quantile PR01,PR07" \

pandas/_libs/tslibs/timestamps.pyx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,35 @@ class Timestamp(_Timestamp):
22082208
"""
22092209
return super().tzname()
22102210
2211+
@property
2212+
def tzinfo(self):
2213+
"""
2214+
Returns the timezone info of the Timestamp.
2215+
2216+
This property returns a `datetime.tzinfo` object if the Timestamp
2217+
is timezone-aware. If the Timestamp has no timezone, it returns `None`.
2218+
If the Timestamp is in UTC or a fixed-offset timezone,
2219+
it returns `datetime.timezone`. If the Timestamp uses an
2220+
IANA timezone (e.g., "America/New_York"), it returns `zoneinfo.ZoneInfo`.
2221+
2222+
See Also
2223+
--------
2224+
Timestamp.tz : Alias for `tzinfo`, may return a `zoneinfo.ZoneInfo` object.
2225+
Timestamp.tz_convert : Convert timezone-aware Timestamp to another time zone.
2226+
Timestamp.tz_localize : Localize the Timestamp to a specific timezone.
2227+
2228+
Examples
2229+
--------
2230+
>>> ts = pd.Timestamp("2023-01-01 12:00:00", tz="UTC")
2231+
>>> ts.tzinfo
2232+
UTC
2233+
2234+
>>> ts_naive = pd.Timestamp("2023-01-01 12:00:00")
2235+
>>> ts_naive.tzinfo
2236+
None
2237+
"""
2238+
return super().tzinfo
2239+
22112240
def utcoffset(self):
22122241
"""
22132242
Return utc offset.

0 commit comments

Comments
 (0)