localize
Convert aware :class:~datetime.datetime to another timezone.
Using a ZoneInfo timezone will give the most flexibility in terms of ambiguous DST handling.
def localize(
dt: datetime,
tz: tzinfo
) - > datetime
Convert aware :class:~datetime.datetime to another timezone. Using a ZoneInfo timezone will give the most flexibility in terms of ambiguous DST handling.
Parameters
| Name | Type | Description |
|---|---|---|
| dt | datetime | The datetime object to be localized; if naive, it will be made aware using the provided timezone. |
| tz | tzinfo | The target timezone information used for localization or conversion. |
Returns
| Type | Description |
|---|---|
datetime | The timezone-aware datetime object converted to the target timezone. |