[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 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
embedded-iot

调研方向

首先,在 Raspberry Pi Pico 上使用 MicroPython v1.23.0 和通过 mip 安装的 datetime 库复现发现代码。检查该软件包使用的 datetime 实现,并验证在添加 timedelta 后,timetuple() 报告的是更新后的 datetime 值。

由索引模型根据 Issue 内容生成。

描述

--- 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)
主要语言
Python
星标
2.9k
派生
1.1k
平均合并
7 天 6 小时
30 天内合并 PR
3

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

micropython/micropython-lib 的其他 Issue

查看 micropython/micropython-lib 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。