This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: datetime.utctimetuple() should not set tm_isdst flag to 0
类型: behavior Stage: patch review
Components: Documentation Versions: Python 3.6
process
状态: open Resolution:
Dependencies: 后续:
分配给: belopolsky 抄送列表: Gaurav Tatke, belopolsky, eric.araujo, hobbestigrou, karlcow, lemburg, p-ganssle, pitrou
优先级: normal 关键字: easy, patch

belopolsky2010-06-16 03:36 创建。最近一次由 admin2022-04-11 14:57 修改。

文件
文件名 上传时间 Description 编辑
timetuple_issue9004.patch Gaurav Tatke, 2016-12-27 08:16 review
Pull Requests
URL Status Linked Edit
PR 10870 closed belopolsky, 2018-12-03 18:52
PR 15773 karlcow, 2019-10-03 09:54
Messages (8)
msg107906 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) 日期: 2010-06-16 03:36
I find the following quite misleading:

>>> from datetime import datetime
>>> import time
>>> time.strftime('%c %z %Z', datetime.utcnow().utctimetuple())
'Wed Jun 16 03:26:26 2010 -0500 EST'

As far as I can tell, the only other function that uses the tm_isdst flag is time.mktime, but it expect a timetuple containing local time, not UTC time.
msg108278 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) 日期: 2010-06-21 15:35
With timezone.utc available in datetime module, users should be encouraged to use dt.astimezone(timezone.utc).timetuple() instead of dt.utctimetuple().  Note that the later will set tm_isdst to -1.  This observation can be used to argue for either of two ways to resolve this issue:

1. Since utctimetuple() is no longer necessary, and the alternative works correctly, there is no need to fix it.  Just recommend the astimezone use in the docs and explain the subtle difference.

2. Having two ways to do the same thing which have a subtle difference is not a good idea.

I am leaning towards #1, but would like to hear from others.
msg162633 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) 日期: 2012-06-11 18:04
> Just recommend the astimezone use in the docs
and recommend creating tz-aware instances in the first time (i.e. calling now(utc) instead of utcnow()), +1.
msg221894 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) 日期: 2014-06-29 20:13
Reclassifying this as a doc issue.
msg284072 - (view) Author: Gaurav Tatke (Gaurav Tatke) * 日期: 2016-12-27 08:16
Hi,
I am new to python and would like to contribute. I find this issue easy so changed the documentation of datetime module. I tested it with sphinx. Attaching a patch.

Please let me know if it is correct or needs changes.
Appreciate it!

Regards,
Gaurav
msg330963 - (view) Author: Natal Ngétal (hobbestigrou) * 日期: 2018-12-03 17:53
Please can you convert your patch to a pull request on github.
msg330969 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) 日期: 2018-12-03 18:53
I submitted Gaurav's patch as PR 10870.  Please review.
msg353837 - (view) Author: karl (karlcow) * 日期: 2019-10-03 09:54
@gaurav The pull request 
https://github.com/python/cpython/pull/10870
has been closed in favor of 
https://github.com/python/cpython/pull/15773
which has already been merged.

So we can probably close here.
历史
日期 用户 动作 参数
2022-04-11 14:57:02admin修改github: 53250
2019-10-03 09:54:22karlcow修改抄送: + karlcow

消息: + msg353837
pull_requests: + pull_request16145
2018-12-03 18:53:43belopolsky修改消息: + msg330969
2018-12-03 18:52:14belopolsky修改stage: needs patch -> patch review
pull_requests: + pull_request10105
2018-12-03 17:53:07hobbestigrou修改抄送: + hobbestigrou
消息: + msg330963
2018-07-05 15:56:46p-ganssle修改抄送: + p-ganssle
2016-12-27 08:16:08Gaurav Tatke修改文件: + timetuple_issue9004.patch

抄送: + Gaurav Tatke
消息: + msg284072

keywords: + patch
2016-09-18 10:05:50mark.dickinson修改抄送: - mark.dickinson
2016-09-10 18:38:37belopolsky修改versions: + Python 3.6, - Python 3.5
2014-06-29 20:15:06belopolsky修改keywords: + easy
2014-06-29 20:13:35belopolsky修改stage: test needed -> needs patch
消息: + msg221894
components: + Documentation, - Extension Modules
versions: + Python 3.5, - Python 3.3
2014-06-29 20:12:02belopolsky修改抄送: + lemburg
2012-06-11 18:04:22eric.araujo修改抄送: + eric.araujo
消息: + msg162633
2011-01-11 02:04:01belopolsky修改versions: + Python 3.3, - Python 3.2
2010-07-05 19:35:32belopolsky修改抄送: + pitrou
2010-06-21 15:35:16belopolsky修改消息: + msg108278
2010-06-16 03:36:41belopolsky创建