Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datetime().astimezone() is broken #4982

Open
xiaxinmeng opened this issue May 20, 2023 · 1 comment
Open

datetime().astimezone() is broken #4982

xiaxinmeng opened this issue May 20, 2023 · 1 comment
Labels
A-stdlib C-bug Something isn't working

Comments

@xiaxinmeng
Copy link

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

@DimitrisJim DimitrisJim added C-bug Something isn't working A-stdlib labels May 20, 2023
@DimitrisJim
Copy link
Member

both tm_gmtoff and tm_zone are missing from the struct_time struct:

struct PyStructTime {
tm_year: PyObjectRef,
tm_mon: PyObjectRef,
tm_mday: PyObjectRef,
tm_hour: PyObjectRef,
tm_min: PyObjectRef,
tm_sec: PyObjectRef,
tm_wday: PyObjectRef,
tm_yday: PyObjectRef,
tm_isdst: PyObjectRef,
}

reference, Python docs on these: https://docs.python.org/3/library/time.html#time.struct_time

Might be easy to add them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-stdlib C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants