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
| Name | Type | Description |
|---|---|---|
| dt | datetime | The date and time object used to determine if daylight saving time is active |
Returns
| Type | Description |
|---|---|
timedelta | The 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
| Name | Type | Description |
|---|---|---|
| dt | datetime | The date and time object to evaluate for daylight saving status |
Returns
| Type | Description |
|---|---|
timedelta | The 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
| Name | Type | Description |
|---|---|---|
| dt | datetime | The date and time object used to select between standard and daylight saving names |
Returns
| Type | Description |
|---|---|
string | The 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
| Name | Type | Description |
|---|---|---|
| dt | datetime | The UTC datetime object to be converted |
Returns
| Type | Description |
|---|---|
datetime | A datetime object adjusted to the local timezone |