[Python-Dev] dateutil

Greg Ewing greg at cosc.canterbury.ac.nz
Mon Mar 15 20:05:28 EST 2004


Aahz <aahz at pythoncraft.com>:

> Part of the problem is that relativedelta does need to be a single
> complex object.  Consider
> 
> today() + relativedelta(month=1, dayofweek=FRIDAY)
> 
> contrasted with
> 
> today() + relativedelta(weeks=4, dayofweek=FRIDAY)

I'm not sure what point you're trying to make here. Even
if it's true that a single composite operation is required,
I don't see any reason it has to be written using the '+'
operator.

Moreover, your first example tends to suggest that a single
composite operation is *not* always what is needed. Written
that way, it's ambiguous whether it means to go to a Friday
and then forward one month, or to go forward one month and
then to a Friday, which could give a different result.

It seems to me there are really two consecutive operations
there, and their order matters. Given that, it would seem
more sensible to write it as something like

  d2 = friday_of(next_month(d1))

or

  d2 = next_month(friday_of(d1))

depending on which one you want.

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