Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue9256

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:plistlib should create non-naïve datetime objects
Type:behaviorStage:needs patch
Components:Library (Lib), macOSVersions:Python 3.5
process
Status:openResolution:
Dependencies:Superseder:
Assigned To: ronaldoussorenNosy List: belopolsky, hynek, ned.deily, r.david.murray, ronaldoussoren, wiml
Priority:normalKeywords:

Created on2010-07-14 01:34 bywiml, last changed2022-04-11 14:57 byadmin.

Files
File nameUploadedDescriptionEdit
plistdt.pywiml,2010-07-14 01:34a simple test case
Messages (3)
msg110249 -(view)Author: Wim (wiml)Date: 2010-07-14 01:34
The plistlib module parses <date> elements in the plist into datetime objects. (This is good.) However, it produces naïve datetimes, even though the <date> elements include an explicit timezone specification ('Z' for UTC, since they're in ISO 8601 format).Now thatissue 5094 has been fixed, this should be a pretty trivial thing to fix— just pass tzinfo=UTC when creating the datetime (since the regex it uses won't even accept a date that doesn't have the 'Z' suffix, this will be correct).As an aside: RFC 3339 section 4.3 suggests a convention for distinguishing between "timestamps in UTC" and "timestamps which happen to be defined in terms of UTC, but don't really live in any particular timezone". The python datetime module is not currently able to make this distinction AFAIK, but even though the plist date strings don't follow the RFC 3339 convention, they are most accurately described as having an unknown local offset (like POSIX timestamps, they are UTC-referenced but cannot carry local-timezone info).
msg110250 -(view)Author: Alexander Belopolsky (belopolsky)*(Python committer)Date: 2010-07-14 01:42
Yes, parsing <date> elements ending with 'Z' into aware datetime objects makes perfect sense, but this should be done carefully because doing so will break any code that mixes the result with naive datetimes.There is a lengthy RFC 3339 discussion inissue 7584.
msg162471 -(view)Author: R. David Murray (r.david.murray)*(Python committer)Date: 2012-06-07 12:48
An alternative is to do what the email package in 3.3 does, and treat naive datetimes as exactly "UTC referenced but with no information as to what local timezone they originated in".  Either way, a program using the plistlib is going to have to know about this and handle the distinction itself, since as you say datetime doesn't have a way to make this differentiation (other than naive vs aware).  So it needs to be documented clearly if it isn't already.
History
DateUserActionArgs
2022-04-11 14:57:03adminsetgithub: 53502
2014-06-30 00:02:22belopolskysetassignee:ronaldoussoren
components: + macOS
2014-06-30 00:00:52belopolskysetassignee:belopolsky -> (no value)

nosy: +ronaldoussoren,ned.deily,hynek
versions: + Python 3.5, - Python 3.2
2012-06-07 12:48:48r.david.murraysetmessages: +msg162471
2012-06-07 03:52:03belopolskysetnosy: +r.david.murray
2010-07-14 01:42:11belopolskysetassignee:belopolsky
components: + Library (Lib)
versions: + Python 3.2, - Python 2.6, Python 2.5
nosy: +belopolsky

messages: +msg110250
stage: needs patch
2010-07-14 01:34:02wimlcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp