TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Python Enhancement Proposal 495: Local Time Disambiguation

51 点作者 philipn将近 10 年前

6 条评论

kbenson将近 10 年前
I&#x27;m not sure the rationale behind this. That is, the rationale section of the proposal does a poor just of explaining any case where this is actually a problem.<p>In every case where I&#x27;ve seen this problem, it&#x27;s a matter of people either not storing the timezone along with the local time, or not storing in UTC time. A local time with a timezone is a unique time, it does not occur twice. A UTC time additionally does not occur twice. Store a time zone along with the date and time or store in UTC and convert on use.<p>Note: If there are instances where a second is repeated, it&#x27;s rare special occurrence that developing a formalized interface for seems like overkill.
评论 #10098354 未加载
评论 #10096391 未加载
评论 #10096933 未加载
评论 #10097426 未加载
评论 #10096330 未加载
toyg将近 10 年前
Terrible PEP, I hope it gets rejected. One-off flags like this are hacks that shouldn&#x27;t be in stdlib. It simply stinks, in an area (time handling) where the stdlib does not really smell like roses already.<p>Dealing with time adjustments is the OS&#x27;s job, not userland. If your job has to be scheduled exactly and cannot rely on the OS, and you refuse to deal with UTC, it&#x27;s your own damn fault and you can always just use a long-running process with timers.
评论 #10097001 未加载
lifeisstillgood将近 10 年前
So :<p>Time in UK is currently UTC +1 (BST) At 2am on 25 OCT we will return to GMT &#x2F; UTC. It will therefore become 1am, and for the next hour all times will have happened before<p>The idea is to put a bit flag that says &quot;alreadyseenthistime&quot;<p>It seems to me this is a solution to the wrong problem.<p>Store all strings as bytes, assuming UTF-8, store all times as longs assuming UTC<p>If we convert all python datelines to non-naive (ie embedded with a TZ) then we are forced always to choose an encoding just like in strings. The right encoding is to always assume incoming dates are UTC, to throw error if they are non naive, and to assume that local clocks are set correctly (which we do anyway)<p>I need to read it more carefully - but it seems the wrong solution
Marazan将近 10 年前
In general any solution to datetimes that doesn&#x27;t involve the time being in UTC is solving thew wrong problem.
评论 #10096991 未加载
IanCal将近 10 年前
When the clocks change, don&#x27;t you shift timezone? There aren&#x27;t duplicate times in BST, we just switch from GMT to BST and then back.<p>&gt; In these situations, the information displayed on a local clock (or stored in a Python datetime instance) is insufficient to identify a particular moment in time.<p>Does the datetime instance not store the timezone?
评论 #10096664 未加载
评论 #10096211 未加载
评论 #10096350 未加载
mayoff将近 10 年前
The more I&#x27;m exposed to other date&#x2F;time libraries, the more impressed I become with Apple&#x27;s date&#x2F;time library.<p><a href="https:&#x2F;&#x2F;developer.apple.com&#x2F;library&#x2F;mac&#x2F;documentation&#x2F;Cocoa&#x2F;Conceptual&#x2F;DatesAndTimes&#x2F;DatesAndTimes.html#&#x2F;&#x2F;apple_ref&#x2F;doc&#x2F;uid&#x2F;10000039-SW1" rel="nofollow">https:&#x2F;&#x2F;developer.apple.com&#x2F;library&#x2F;mac&#x2F;documentation&#x2F;Cocoa&#x2F;...</a>