Visitar URL original
datetime().astimezone() is broken · Issue #4982 · RustPython/RustPython · GitHub
The Wayback Machine - https://web.archive.org/web/20260623083031/https://github.com/RustPython/RustPython/issues/4982
Skip to content

datetime().astimezone() is broken #4982

Description

@xiaxinmeng

It seems that RustPython supports datetime().astimezone() while the implementation of this function is broken and attribute 'tm_gmtoff' is missing. See the following example.

Example.py

from datetime import datetime
datetime(3001, 1, 19, 7, 59, 59, 999999).astimezone() 

Output on RustPython:

Traceback (most recent call last):
  File "/home/xxm/Desktop/RustPython/example.py", line 199, in <module>
    datetime(3001, 1, 19, 7, 59, 59, 999999).astimezone() 
  File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/59df92d/pylib/Lib/datetime.py", line 1862, in astimezone
    tz = self._local_timezone()
  File "/home/xxm/.cargo/git/checkouts/rustpython-f8ef4d934ac33cd8/59df92d/pylib/Lib/datetime.py", line 1856, in _local_timezone
    gmtoff = localtm.tm_gmtoff
AttributeError: 'struct_time' object has no attribute 'tm_gmtoff'

Behavior on CPython: works normally

Environment:
RustPython: v0.2.0 (https://github.com/RustPython/RustPython#59df92d7)
CPython: 3.9.0
Ubuntu 18.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions