Time Utilities¶
Timezone Class¶
-
class
mtldp.utils.
Timezone
(lon=0, lat=0, name=None)¶ Class for a timezone
- Main Attributes
-
.timezone
: pytz.tzfile -.utcoffset
: difference in seconds between current timezone and UTC
-
__init__
(lon=0, lat=0, name=None)¶ Note: Either lon&lat or name should be specified. An acceptable name can be found here: https://gist.github.com/heyalexej/8bf688fd67d7199be4a1682b3eec7568
- Parameters
lon – float, longitude of the timezone default 0
lat – float, latitude of the timezone default 0
name – str, name of the timezone, default None
-
__str__
()¶ Get timezone name (example: “US/Eastern”, “Asia/Shanghai”)
- Returns
str
-
daylight_saving_offset
(date=None, timestamp=None)¶ Get time offset (in second) for converting winter time to summer time At least one of date and timestamp should be specified
- Parameters
date – str, local date in format “yyyy-mm-dd”, if None, use timestamp
timestamp – if None, use date
- Returns
int, 0 if date or timestamp is already in summer time
- Return type