TimezoneInfo¶
-
class
astropy.time.
TimezoneInfo
(utc_offset=<Quantity 0.0 d>, dst=<Quantity 0.0 d>, tzname=None)[source] [edit on github]¶ Bases:
datetime.tzinfo
Subclass of the
tzinfo
object, used in the to_datetime method to specify timezones.It may be safer in most cases to use a timezone database package like pytz rather than defining your own timezones - this class is mainly a workaround for users without pytz.
Parameters: utc_offset :
Quantity
(optional)Offset from UTC in days. Defaults to zero.
dst :
Quantity
(optional)Daylight Savings Time offset in days. Defaults to zero (no daylight savings).
tzname : string,
None
(optional)Name of timezone
Examples
>>> from datetime import datetime >>> from astropy.time import TimezoneInfo # Specifies a timezone >>> import astropy.units as u >>> utc = TimezoneInfo() # Defaults to UTC >>> utc_plus_one_hour = TimezoneInfo(utc_offset=1*u.hour) # UTC+1 >>> dt_aware = datetime(2000, 1, 1, 0, 0, 0, tzinfo=utc_plus_one_hour) >>> print(dt_aware) 2000-01-01 00:00:00+01:00 >>> print(dt_aware.astimezone(utc)) 1999-12-31 23:00:00+00:00
Methods Summary
dst
(dt)tzname
(dt)utcoffset
(dt)Methods Documentation
-
dst
(dt)[source] [edit on github]¶
-
tzname
(dt)[source] [edit on github]¶
-
utcoffset
(dt)[source] [edit on github]¶
-