Skip to main content

LocalTimezone

Local time implementation. Provided in _Zone to the app when enable_utc is disabled. Otherwise, _Zone provides a UTC ZoneInfo instance as the timezone implementation for the application.

Constructor​

Signature​

def LocalTimezone() - > None

Signature​

def LocalTimezone()

Methods​


utcoffset()​

@classmethod
def utcoffset(
dt: datetime
) - > timedelta

Calculates the total offset from UTC for a given date and time, accounting for daylight saving time if applicable.

Parameters​

NameTypeDescription
dtdatetimeThe date and time object used to determine if daylight saving time is active

Returns​

TypeDescription
timedeltaThe duration representing the total offset from UTC

dst()​

@classmethod
def dst(
dt: datetime
) - > timedelta

Determines the daylight saving time adjustment for a specific date and time.

Parameters​

NameTypeDescription
dtdatetimeThe date and time object to evaluate for daylight saving status

Returns​

TypeDescription
timedeltaThe daylight saving offset if active, otherwise a zero duration

tzname()​

@classmethod
def tzname(
dt: datetime
) - > string

Retrieves the name of the timezone for the provided date and time based on system locale.

Parameters​

NameTypeDescription
dtdatetimeThe date and time object used to select between standard and daylight saving names

Returns​

TypeDescription
stringThe alphanumeric name of the timezone, such as 'EST' or 'EDT'

fromutc()​

@classmethod
def fromutc(
dt: datetime
) - > datetime

Converts a UTC datetime to a local datetime by applying the appropriate offset and caching the resulting timezone info.

Parameters​

NameTypeDescription
dtdatetimeThe UTC datetime object to be converted

Returns​

TypeDescription
datetimeA datetime object adjusted to the local timezone