Re: [Python-Dev] TZ-aware local time

2012-06-13 Thread Alexander Belopolsky
On Tue, Jun 12, 2012 at 1:14 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: To the contrary, without the POSIX timestamp model to define the equivalency between the same point in time expressed using different timezones, sane comparisons and arithmetic on timestamps would be impossible.

Re: [Python-Dev] TZ-aware local time

2012-06-11 Thread Alexander Belopolsky
On Fri, Jun 8, 2012 at 11:06 PM, Guido van Rossum gu...@python.org wrote: On Fri, Jun 8, 2012 at 2:08 PM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: .. t = mktime((2010, 11, 7, 1, 0, 0, -1, -1, 0)) for i in range(5): ...     print(strftime(%T%z, localtime(t + i - 2))) ...

Re: [Python-Dev] TZ-aware local time

2012-06-11 Thread Guido van Rossum
On Mon, Jun 11, 2012 at 6:33 AM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: On Fri, Jun 8, 2012 at 11:06 PM, Guido van Rossum gu...@python.org wrote: On Fri, Jun 8, 2012 at 2:08 PM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: .. t = mktime((2010, 11, 7, 1, 0, 0,

Re: [Python-Dev] TZ-aware local time

2012-06-11 Thread R. David Murray
On Mon, 11 Jun 2012 10:01:57 -0700, Guido van Rossum gu...@python.org wrote: On Mon, Jun 11, 2012 at 6:33 AM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: On Fri, Jun 8, 2012 at 11:06 PM, Guido van Rossum gu...@python.org wrote: On Fri, Jun 8, 2012 at 2:08 PM, Alexander

Re: [Python-Dev] TZ-aware local time

2012-06-11 Thread Alexander Belopolsky
On Mon, Jun 11, 2012 at 1:01 PM, Guido van Rossum gu...@python.org wrote: .. Maybe the problem here is the *input*? It should be a POSIX timestamp, not a datetime object. No. Seconds since epoch or POSIX timestamp is a foreign data type to the datetime module. An aware datetime object with

Re: [Python-Dev] TZ-aware local time

2012-06-11 Thread Guido van Rossum
Let's agree to disagree. I don't have the time to argue any more but you haven't convinced me. On Mon, Jun 11, 2012 at 11:42 AM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: On Mon, Jun 11, 2012 at 1:01 PM, Guido van Rossum gu...@python.org wrote: .. Maybe the problem here is the

Re: [Python-Dev] TZ-aware local time

2012-06-11 Thread Ben Finney
Alexander Belopolsky alexander.belopol...@gmail.com writes: On Mon, Jun 11, 2012 at 1:01 PM, Guido van Rossum gu...@python.org wrote: Maybe the problem here is the *input*? It should be a POSIX timestamp, not a datetime object. No. Seconds since epoch or POSIX timestamp is a foreign data

Re: [Python-Dev] TZ-aware local time

2012-06-11 Thread Guido van Rossum
On Mon, Jun 11, 2012 at 7:10 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Alexander Belopolsky alexander.belopol...@gmail.com writes: On Mon, Jun 11, 2012 at 1:01 PM, Guido van Rossum gu...@python.org wrote: Maybe the problem here is the *input*? It should be a POSIX timestamp, not a

Re: [Python-Dev] TZ-aware local time

2012-06-11 Thread Ben Finney
Guido van Rossum gu...@python.org writes: On Mon, Jun 11, 2012 at 7:10 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Unambiguous storage of absolute time can be achieved with POSIX timestamps, but that is certainly not the only nor best way to do it. For example, RFC 5322

Re: [Python-Dev] TZ-aware local time

2012-06-08 Thread Alexander Belopolsky
On Tue, Jun 5, 2012 at 6:07 PM, Guido van Rossum gu...@python.org wrote: See http://bugs.python.org/issue9527 . With datetime.timestamp() method committed, I would like to get back to this issue. In some sense, an inverse of datetime.timestamp() is missing from the datetime module. Given a

Re: [Python-Dev] TZ-aware local time

2012-06-08 Thread Guido van Rossum
On Fri, Jun 8, 2012 at 2:08 PM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: On Tue, Jun 5, 2012 at 6:07 PM, Guido van Rossum gu...@python.org wrote: See http://bugs.python.org/issue9527 . With datetime.timestamp() method committed, I would like to get back to this issue. What

Re: [Python-Dev] TZ-aware local time

2012-06-06 Thread Ben Finney
MRAB pyt...@mrabarnett.plus.com writes: datetime objects would consist of the UTC time, time zone and DST. “time zone” information always entails DST information doesn't it? It isn't proper time zone information if it doesn't tell you about DST. That is, when you know the full time zone

Re: [Python-Dev] TZ-aware local time

2012-06-06 Thread M.-A. Lemburg
Just to add my 2 cents to this discussion as someone who's worked with mxDateTime for almost 15 years. I think we all agree that users of an application want to input date/time data using their local time (which may very well not be the timezone of the system running the application). On output

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Guido van Rossum
On Tue, Jun 5, 2012 at 11:29 AM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: Changing subject to reflect a change of topic. On Tue, Jun 5, 2012 at 2:19 PM, Guido van Rossum gu...@python.org wrote: .. Although if we ever get that local time tzinfo object, we may regret it. So I

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Alexander Belopolsky
On Tue, Jun 5, 2012 at 6:07 PM, Guido van Rossum gu...@python.org wrote: I've also been arguing against local time tzinfo Why? I don't see your argumentation against such a tzinfo in the bug See http://bugs.python.org/issue9063 . The problem is again the DST ambiguity. One day a year,

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Guido van Rossum
On Tue, Jun 5, 2012 at 3:33 PM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: On Tue, Jun 5, 2012 at 6:07 PM, Guido van Rossum gu...@python.org wrote: I've also been arguing against local time tzinfo Why? I don't see your argumentation against such a tzinfo in the bug See

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Alexander Belopolsky
On Tue, Jun 5, 2012 at 6:49 PM, Guido van Rossum gu...@python.org wrote: The problem is again the DST ambiguity.  One day a year, datetime(y, m, d, 1, 30, tzinfo=Local) represents two different times and another day it represents no valid time.  Many applications can ignore this problem but

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Barry Warsaw
On Jun 05, 2012, at 07:41 PM, Alexander Belopolsky wrote: The second feature has its uses. If I want wake up at 7 AM every weekday, I don't want my alarm clock ask me whether I mean standard or daylight saving time, but if I attempt to set it to 1:30 AM on the day when 1:30 AM happens twice, I

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 10:18 AM, Barry Warsaw ba...@python.org wrote: On Jun 05, 2012, at 07:41 PM, Alexander Belopolsky wrote: The second feature has its uses.  If I want wake up at 7 AM every weekday, I don't want my alarm clock ask me whether I mean standard or daylight saving time, but if I

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Alexander Belopolsky
On Tue, Jun 5, 2012 at 8:18 PM, Barry Warsaw ba...@python.org wrote: I think stdlib should allow me to write a robust application that knows that some naive datetime objects correspond to two points in time and some correspond to none. Really?  Why would naive datetimes know that?  I would

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Glyph
Le Jun 5, 2012 à 6:16 PM, Nick Coghlan a écrit : Personally, I'd like to see the datetime module make an explicit assumption that all naive datetime objects are considered to be UTC, with the interactions between naive and aware objects updated accordingly I would absolutely love it if this

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Alexander Belopolsky
On Tue, Jun 5, 2012 at 9:16 PM, Nick Coghlan ncogh...@gmail.com wrote: ... Local time should only be used for displaying dates and times to humans (since we care about little things like local sunrise and sunset, local business hours, etc) and for inter-system coordination where such details

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Greg Ewing
Alexander Belopolsky wrote: The problem is again the DST ambiguity. One day a year, datetime(y, m, d, 1, 30, tzinfo=Local) represents two different times and another day it represents no valid time. The documentation example (fixed in issue 9063) addresses the ambiguity by defaulting to

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Alexander Belopolsky
On Tue, Jun 5, 2012 at 7:11 PM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: What would be so bad about giving datetime objects a DST flag? Apps that don't care could ignore it and get results no worse than the status quo. This would neatly solve the round-trip problem, but will open a

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread R. David Murray
On Tue, 05 Jun 2012 18:31:20 -0700, Glyph gl...@twistedmatrix.com wrote: Le Jun 5, 2012 à 6:16 PM, Nick Coghlan a écrit : Personally, I'd like to see the datetime module make an explicit assumption that all naive datetime objects are considered to be UTC, with the interactions between

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 11:57 AM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: On Tue, Jun 5, 2012 at 7:11 PM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: What would be so bad about giving datetime objects a DST flag? Apps that don't care could ignore it and get results no

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Guido van Rossum
On Tue, Jun 5, 2012 at 7:44 PM, Nick Coghlan ncogh...@gmail.com wrote: On Wed, Jun 6, 2012 at 11:57 AM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: On Tue, Jun 5, 2012 at 7:11 PM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: What would be so bad about giving datetime objects

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Guido van Rossum
On Tue, Jun 5, 2012 at 6:39 PM, Alexander Belopolsky alexander.belopol...@gmail.com wrote: On Tue, Jun 5, 2012 at 9:16 PM, Nick Coghlan ncogh...@gmail.com wrote: ...  Local time should only be used for displaying dates and times to humans (since we care about little things like local sunrise

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Guido van Rossum
On Tue, Jun 5, 2012 at 6:31 PM, Glyph gl...@twistedmatrix.com wrote: Le Jun 5, 2012 à 6:16 PM, Nick Coghlan a écrit : Personally, I'd like to see the datetime module make an explicit assumption that all naive datetime objects are considered to be UTC, with the interactions between naive and

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread MRAB
On 06/06/2012 02:57, Alexander Belopolsky wrote: On Tue, Jun 5, 2012 at 7:11 PM, Greg Ewinggreg.ew...@canterbury.ac.nz wrote: What would be so bad about giving datetime objects a DST flag? Apps that don't care could ignore it and get results no worse than the status quo. This would neatly

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 1:14 PM, Guido van Rossum gu...@python.org wrote: You can try to enforce this, but users will ignore it, and happily represent local time as UTC. I've seen people do this with POSIX timestamps too -- use the UTC conversions between timestamps and time tuples, and yet use

Re: [Python-Dev] TZ-aware local time

2012-06-05 Thread Guido van Rossum
On Tue, Jun 5, 2012 at 8:41 PM, Nick Coghlan ncogh...@gmail.com wrote: On Wed, Jun 6, 2012 at 1:14 PM, Guido van Rossum gu...@python.org wrote: You can try to enforce this, but users will ignore it, and happily represent local time as UTC. I've seen people do this with POSIX timestamps too --