Skip to content

timezones

utilities.timezones ¤

Functions¤

to_local_time(utc_time) ¤

Converts a UTC time to a local time.

Parameters:

Name Type Description Default
utc_time datetime

UTC time.

required

Returns:

Type Description
datetime

Local time.

Source code in utilities\timezones.py
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def to_local_time(utc_time: timezone.datetime) -> timezone.datetime:
    """Converts a UTC time to a local time.

    Args:
        utc_time: UTC time.

    Returns:
        Local time.
    """
    tz = timezone.get_current_timezone()
    return utc_time.astimezone(tz)