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)
dst : Quantity (optional)
tzname : string, None (optional)
|
---|
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