[Python-Dev] dateutil
Greg Ewing
greg at cosc.canterbury.ac.nz
Mon Mar 15 17:59:09 EST 2004
> In dateutil, I think it's d + relativedelta(months=+1, day=1, days=-1).
> Arguably, this is fairly trivial (highly non-obvious, but trivial...)
Another thing that occurs to me. Presumably
d + relativedelta(months=+1) + relativedelta(days=-1)
is not necessarily the same as
d + relativedelta(days=-1) + relativedelta(months=+1)
so when you add two relativedeltas together, do you get
a relativedelta that does things in the right order?
In other words, can you do
rd = relativedelta(days=-1) + relativedelta(months=+1)
d += rd
and get the same result as
d += relativedelta(days=-1)
d += relativedelta(months=+1)
Also, there is presumably some order of precedence defined
when you specify multiple adjustments in one constructor.
>From your examples I'm guessing
relativedelta(months=+1, days=-1) == \
relativedelta(months=+1) + relativedelta(days=-1)
There could be a trap lurking here for the unwary, since
obviously then
relativedelta(days=-1, months=+1) != \
relativedelta(days=-1), relativedelta(months=+1)
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | A citizen of NewZealandCorp, a |
Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. |
greg at cosc.canterbury.ac.nz +--------------------------------------+
More information about the Python-Dev
mailing list