mycroft.util.time¶
Time utils for getting and converting datetime objects for the Mycroft system. This time is based on the setting in the Mycroft config and may or may not match the system locale.
- mycroft.util.time.default_timezone()[source]¶
Get the default timezone
Based on user location settings location.timezone.code or the default system value if no setting exists.
- Returns
Definition of the default timezone
- Return type
(datetime.tzinfo)
- mycroft.util.time.now_local(tz=None)[source]¶
Retrieve the current time
- Parameters
tz (datetime.tzinfo, optional) – Timezone, default to user’s settings
- Returns
The current time
- Return type
(datetime)
- mycroft.util.time.now_utc()[source]¶
Retrieve the current time in UTC
- Returns
The current time in Universal Time, aka GMT
- Return type
(datetime)
- mycroft.util.time.to_local(dt)[source]¶
Convert a datetime to the user’s local timezone
- Parameters
dt (datetime) – A datetime (if no timezone, defaults to UTC)
- Returns
time converted to the local timezone
- Return type
(datetime)