datetime.tzoffset
datetime: DT = tzoffset (T)
Time zone offset of a datetime array.
DT = tzoffset (T) returns the offset from UTC of each
element of the input datetime array T as a duration array
DT of the same size as T. The offset is positive for time
zones east of UTC and includes the additional hour when daylight saving
time is in effect. If T has no time zone, or for Not-A-Time
(NaT) values, the corresponding offset is NaN.
Source Code: datetime
tzoffset gives each element's offset from UTC as a duration. Because the offset depends on daylight saving time, the same zone reports a different value in winter and in summer.
winter = datetime (2024, 1, 15, 'TimeZone', 'America/New_York')
winter = datetime 15-Jan-2024
tzoffset (winter)
ans = duration -05:00
summer = datetime (2024, 7, 15, 'TimeZone', 'America/New_York')
summer = datetime 15-Jul-2024
tzoffset (summer)
ans = duration -04:00