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

[lib: datetime] Updation of a datetime object with a timedelta obj reflects the change in the datetime object but is not reflected in the value returned by the timetuple() function #911

Open
veethahavya-CU-cz opened this issue Aug 21, 2024 · 0 comments

Comments

@veethahavya-CU-cz
Copy link

--- MicroPython v1.23.0 on 2024-06-02; Raspberry Pi Pico with RP2040 ---
-- Datetime library installed via mip (mpremote) so: mpremote mip install datetime

Discovery code:

>>> from datetime import datetime, timedelta
>>> from utime import time, localtime, mktime

>>> interval_s = 5 * 60
>>> intervals_passed_in_hr = total_seconds_this_hr // interval_s
>>> next_interval_seconds_in_hr = (intervals_passed_in_hr + 1) * interval_s
>>> seconds_to_next_interval = next_interval_seconds_in_hr - total_seconds_this_hr
>>> next_record_time_dt = now + timedelta(seconds=seconds_to_next_interval)

>>> now
datetime.datetime(2024, 8, 21, 14, 53, 39, 0, None, fold=0)
>>> next_record_time_dt
datetime.datetime(2024, 8, 21, 14, 55, 0, 0, None, fold=0)
>>> next_record_time_dt.timetuple()[:-2]
(2024, 8, 21, 14, 53, 52)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant