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

2012-06-13 Thread Alexander Belopolsky
On Tue, Jun 12, 2012 at 1:14 AM, Ben Finney 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. > > Why is the POSIX ti

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

2012-06-11 Thread Ben Finney
Guido van Rossum writes: > On Mon, Jun 11, 2012 at 7:10 PM, Ben Finney > 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 specifies a standard serialisation for

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 wrote: > Alexander Belopolsky writes: > >> On Mon, Jun 11, 2012 at 1:01 PM, Guido van Rossum wrote: >> > Maybe the problem here is the *input*? It should be a POSIX >> > timestamp, not a datetime object. >> >> No. "Seconds since epoch" or "POSIX" times

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

2012-06-11 Thread Ben Finney
Alexander Belopolsky writes: > On Mon, Jun 11, 2012 at 1:01 PM, Guido van Rossum 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. On th

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 wrote: > On Mon, Jun 11, 2012 at 1:01 PM, Guido van Rossum wrote: > .. >> Maybe the problem here is the *input*? It should be a POSIX timestamp, >

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 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 tzinfo=time

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 wrote: > On Mon, Jun 11, 2012 at 6:33 AM, Alexander Belopolsky > wrote: > > On Fri, Jun 8, 2012 at 11:06 PM, Guido van Rossum wrote: > >> On Fri, Jun 8, 2012 at 2:08 PM, Alexander Belopolsky > >> wrote: > > .. > >> t = mktime((2010, 11, 7

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 wrote: > On Fri, Jun 8, 2012 at 11:06 PM, Guido van Rossum wrote: >> On Fri, Jun 8, 2012 at 2:08 PM, Alexander Belopolsky >> wrote: > .. >> t = mktime((2010, 11, 7, 1, 0, 0, -1, -1, 0)) >> for i in range(5): >>> ...     print(strftime

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 wrote: > On Fri, Jun 8, 2012 at 2:08 PM, Alexander Belopolsky > 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))) >> ... >> 01:59:58-0400 >> 01:59:59-040

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 wrote: > On Tue, Jun 5, 2012 at 6:07 PM, Guido van Rossum wrote: >>> See http://bugs.python.org/issue9527 . > With datetime.timestamp() method committed, I would like to get back > to this issue. What was committed? The bug only mentions a ch

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 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 POSIX timestam

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 th

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

2012-06-05 Thread Ben Finney
MRAB 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 information, that includes when

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 wrote: > On Wed, Jun 6, 2012 at 1:14 PM, Guido van Rossum 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 betw

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 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 time tuples

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 Ewing 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 proble

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

2012-06-05 Thread Guido van Rossum
On Tue, Jun 5, 2012 at 6:31 PM, Glyph 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 aware objects up

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 wrote: > On Tue, Jun 5, 2012 at 9:16 PM, Nick Coghlan 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

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 wrote: > On Wed, Jun 6, 2012 at 11:57 AM, Alexander Belopolsky > wrote: >> On Tue, Jun 5, 2012 at 7:11 PM, Greg Ewing >> wrote: >>> What would be so bad about giving datetime objects >>> a DST flag? Apps that don't care could ignore it and >>> get re

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

2012-06-05 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 11:57 AM, Alexander Belopolsky wrote: > On Tue, Jun 5, 2012 at 7:11 PM, Greg Ewing > 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 solv

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

2012-06-05 Thread R. David Murray
On Tue, 05 Jun 2012 18:31:20 -0700, Glyph 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 aw

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

2012-06-05 Thread Alexander Belopolsky
On Tue, Jun 5, 2012 at 7:11 PM, Greg Ewing 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 different can of worms: what ha

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 standar

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

2012-06-05 Thread Alexander Belopolsky
On Tue, Jun 5, 2012 at 9:16 PM, Nick Coghlan 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 are relevant. >

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

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

2012-06-05 Thread Alexander Belopolsky
On Tue, Jun 5, 2012 at 8:18 PM, Barry Warsaw 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 expect that a

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

2012-06-05 Thread Nick Coghlan
On Wed, Jun 6, 2012 at 10:18 AM, Barry Warsaw 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 attempt t

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,

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 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 stdlib shou

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 wrote: > On Tue, Jun 5, 2012 at 6:07 PM, Guido van Rossum 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 . > > Th

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 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, datetime(y, m, d,

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 wrote: > Changing subject to reflect a change of topic. > > On Tue, Jun 5, 2012 at 2:19 PM, Guido van Rossum wrote: >> .. Although if we ever get that "local time" tzinfo >> object, we may regret it. So I propose to launch without it and see i

[Python-Dev] TZ-aware local time

2012-06-05 Thread Alexander Belopolsky
Changing subject to reflect a change of topic. On Tue, Jun 5, 2012 at 2:19 PM, Guido van Rossum wrote: > .. Although if we ever get that "local time" tzinfo > object, we may regret it. So I propose to launch without it and see if > people object. There simply isn't a way to roundtrip for times th