localtime
Convert an aware datetime.datetime to local time.
Only aware datetimes are allowed. When value is omitted, it defaults to now().
Local time is defined by the current time zone, unless another time zone is specified.
def localtime(
value: datetime.datetime = None,
timezone: datetime.tzinfo = None
) - > datetime.datetime
Convert an aware datetime.datetime to local time. Only aware datetimes are allowed. When value is omitted, it defaults to now(). Local time is defined by the current time zone, unless another time zone is specified.
Parameters
| Name | Type | Description |
|---|---|---|
| value | datetime.datetime = None | The aware datetime object to be converted; defaults to the current time if not provided. |
| timezone | datetime.tzinfo = None | The target timezone for conversion; defaults to the currently active timezone if not specified. |
Returns
| Type | Description |
|---|---|
datetime.datetime | The datetime object converted to the target timezone, maintaining its point in time but adjusted for the local offset. |