Re: [Python-Dev] Negative timedelta strings

2014-04-02 Thread M.-A. Lemburg
On 02.04.2014 15:04, Skip Montanaro wrote: > On Wed, Apr 2, 2014 at 7:52 AM, M.-A. Lemburg wrote: > print now() + RelativeDateTime(months=+1, day=1) >> 2014-05-01 14:49:05.83 > > I find this sort date arithmetic unintuitive, though I'm at a loss to > come up with better logic than you have: >

Re: [Python-Dev] Negative timedelta strings

2014-04-02 Thread Xavier Morel
On 2014-04-02, at 15:04 , Skip Montanaro wrote: > On Wed, Apr 2, 2014 at 7:52 AM, M.-A. Lemburg wrote: > print now() + RelativeDateTime(months=+1, day=1) >> 2014-05-01 14:49:05.83 > > I find this sort date arithmetic unintuitive, though I'm at a loss to > come up with better logic than you

Re: [Python-Dev] Negative timedelta strings

2014-04-02 Thread Skip Montanaro
On Wed, Apr 2, 2014 at 7:52 AM, M.-A. Lemburg wrote: > >>> print now() + RelativeDateTime(months=+1, day=1) > 2014-05-01 14:49:05.83 I find this sort date arithmetic unintuitive, though I'm at a loss to come up with better logic than you have: >>> d = Date(2014, 2, 28) >>> d + RelativeDateTime(m

Re: [Python-Dev] Negative timedelta strings

2014-04-02 Thread M.-A. Lemburg
n 31.03.2014 21:09, Chris Barker wrote: > On Fri, Mar 28, 2014 at 2:52 PM, Fred Drake wrote: > >> On Fri, Mar 28, 2014 at 5:19 PM, Greg Ewing >> wrote: >>> ISO 8601 doesn't seem to define a representation for >>> negative durations, though, so it wouldn't solve the >>> original problem. >> >> As

Re: [Python-Dev] Negative timedelta strings

2014-03-31 Thread Xavier Morel
On 2014-03-28, at 17:19 , Skip Montanaro wrote: > (*) As an aside (that is, this belongs in a separate thread if you > want to discuss it), in my opinion, attempting to support ISO 8601 > formatting is pointless without the presence of an anchor datetime. > Otherwise how would you know how far bac

Re: [Python-Dev] Negative timedelta strings

2014-03-31 Thread Chris Barker
On Fri, Mar 28, 2014 at 2:52 PM, Fred Drake wrote: > On Fri, Mar 28, 2014 at 5:19 PM, Greg Ewing > wrote: > > ISO 8601 doesn't seem to define a representation for > > negative durations, though, so it wouldn't solve the > > original problem. > > Aside from the horribleness of the ISO 8601 notati

Re: [Python-Dev] Negative timedelta strings

2014-03-28 Thread Marko Rauhamaa
Greg Ewing : > ISO 8601 doesn't seem to define a representation for > negative durations, though, so it wouldn't solve the > original problem. XSD uses ISO 8601 durations and allows a sign before the initial "P". It would appear PT1M means 60 or 61 seconds. P1D means 23, 24 or 25 hours. P1M mean

Re: [Python-Dev] Negative timedelta strings

2014-03-28 Thread Fred Drake
On Fri, Mar 28, 2014 at 5:19 PM, Greg Ewing wrote: > ISO 8601 doesn't seem to define a representation for > negative durations, though, so it wouldn't solve the > original problem. Aside from the horribleness of the ISO 8601 notation for a duration, it's best not to confuse the notions of duratio

Re: [Python-Dev] Negative timedelta strings

2014-03-28 Thread Greg Ewing
Alexander Belopolsky wrote: I meant ISO 8601 syntax for "durations" [1]. ISO 8601 doesn't seem to define a representation for negative durations, though, so it wouldn't solve the original problem. -- Greg ___ Python-Dev mailing list Python-Dev@python

Re: [Python-Dev] Negative timedelta strings

2014-03-28 Thread Skip Montanaro
On Fri, Mar 28, 2014 at 11:07 AM, Alexander Belopolsky wrote: >> Is it open to debate or is it now cast in stone? > > I think the barrier for changing str() is lower than that for changing > repr(), but I would be against any changes in this area. (I may have had a > different view if ISO 8601 sy

Re: [Python-Dev] Negative timedelta strings

2014-03-28 Thread Antoine Pitrou
On Fri, 28 Mar 2014 11:19:52 -0500 Skip Montanaro wrote: > On Fri, Mar 28, 2014 at 11:07 AM, Alexander Belopolsky > wrote: > >> Is it open to debate or is it now cast in stone? > > > > I think the barrier for changing str() is lower than that for changing > > repr(), but I would be against any ch

Re: [Python-Dev] Negative timedelta strings

2014-03-28 Thread Alexander Belopolsky
On Fri, Mar 28, 2014 at 12:19 PM, Skip Montanaro wrote: > (*) As an aside (that is, this belongs in a separate thread if you > want to discuss it), in my opinion, attempting to support ISO 8601 > formatting is pointless without the presence of an anchor datetime. > I meant ISO 8601 syntax for "d

Re: [Python-Dev] Negative timedelta strings

2014-03-28 Thread Alexander Belopolsky
On Fri, Mar 28, 2014 at 7:03 AM, Steven D'Aprano wrote: > py> str(timedelta(0, -1)) > '-1 day, 23:59:59' > .. > Does anyone remember the rationale for this behaviour? I don't recall any better rationale than what I wrote in the docs: "String representations of timedelta objects are normalized si

[Python-Dev] Negative timedelta strings

2014-03-28 Thread Steven D'Aprano
There's a furious discussion going on at the python-list mailing list, about negative timedelta strings: py> str(timedelta(0, -1)) '-1 day, 23:59:59' This is documented. It's even documented as being "somewhat unusual". I found a tracker item for it, back in July 2010: http://bugs.python.org/