[Python-Dev] Status on PEP-431 Timezones (original) (raw)
Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Apr 9 18:55:19 CEST 2015
- Previous message (by thread): [Python-Dev] Status on PEP-431 Timezones
- Next message (by thread): [Python-Dev] Status on PEP-431 Timezones
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Apr 9, 2015 at 11:59 AM, Isaac Schwabacher <ischwabacher at wisc.edu> wrote:
> Storing isdst in the datetime object would allow utcoffset(dt) to distinguish between 1:30AM before clock change and 1:30AM after. Where do you propose to store the offset?
I propose to add an offset field to datetime.datetime. It should be set precisely when the tz field is set, and it should contain either a timedelta or an integer number of (possibly fractional) seconds, depending on what color the bikeshed gets painted. This is, IIUC, precisely where Lennart is proposing to store the isdst flag.
Can you describe a situation where having isdst flag is not sufficient?
Note that in many applications you want to find the appropriate offset knowing only local time and location, so requiring users to supply the offset defeats the purpose of the time zone database. In many applications, the isdst flag can be hidden from the user. For example, a scheduling application can pretend that a repeated hour does not exist and always assume that 01:30 AM is the first 01:30 AM. (In many business applications, it is a good idea anyways.) Alternatively, a user attempting to schedule an event at an ambiguous time can be presented with a warning and a request to pick one of two possible times. This would be a much friendlier interface than the one always requiring the use to specify the UTC offset. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150409/b1bd1c7f/attachment.html>
- Previous message (by thread): [Python-Dev] Status on PEP-431 Timezones
- Next message (by thread): [Python-Dev] Status on PEP-431 Timezones
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]