python / python/cpython

datetime.astimezone() returns DST name for negative timestamp on Windows

未关闭
#148,658 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

interpreter-core OS-windows type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:
PS C:\Users\yukih\Downloads> .\python-3.15.0a8-embed-amd64\python.exe
WARN: Could not find the platform standard library directory! The Python 'home' directory was set to 'C:\\Users\\yukih\\Downloads\\python-3.15.0a8-embed-amd64', is this correct?
Python 3.15.0a8 (tags/v3.15.0a8:55ea59e, Apr  7 2026, 14:21:25) [MSC v.1950 64 bit (AMD64)] on win32
>>> from datetime import datetime
>>>
>>> datetime.fromtimestamp(-1).astimezone()
datetime.datetime(1970, 1, 1, 8, 59, 59, tzinfo=datetime.timezone(datetime.timedelta(seconds=32400), 'Tokyo Daylight Time'))
>>>
>>> datetime.fromtimestamp(0).astimezone()
datetime.datetime(1970, 1, 1, 9, 0, tzinfo=datetime.timezone(datetime.timedelta(seconds=32400), 'Tokyo Standard Time'))

I expected "Tokyo Standard Time".

CPython versions tested on:

3.15

Operating systems tested on:

Windows

Linked PRs
  • gh-148673

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先,在 Windows 上使用 datetime.fromtimestamp(...).astimezone() 重现负时间戳和零时间戳的情况,然后检查 datetime.astimezone 入口点和关联的 PR gh-148673。完成的标准是负时间戳报告预期的名称 "Tokyo Standard Time",且零时间戳的行为没有发生回归。

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

评估

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

把新 issue 发到你的邮箱

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