mycroft.util.time

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)

mycroft.util.time.to_system(dt)[source]

Convert a datetime to the system’s local timezone

Parameters

dt (datetime) – A datetime (if no timezone, assumed to be UTC)

Returns

time converted to the operation system’s timezone

Return type

(datetime)

mycroft.util.time.to_utc(dt)[source]

Convert a datetime with timezone info to a UTC datetime

Parameters

dt (datetime) – A datetime (presumably in some local zone)

Returns

time converted to UTC

Return type

(datetime)