[Python-Dev] dateutil

Gustavo Niemeyer niemeyer at conectiva.com
Mon Mar 15 12:56:13 EST 2004


> > Supporting this might be cool indeed. OTOH, it doesn't replace the
> > current behavior. How do you get (day=30)?
> 
> I don't follow. The semantics would be similar to list indexing.
> 
> `day=30` asks for the 30-est day of the month and raises an ValueError
> if there isn't any. `day=-1` asks for the last day of the month (and
> should never raise an error <wink>).

What advantage do you get with the raised error? The replace() method
of dateutil already does something similar, and I'm not trying to
mimic it. I'm trying to provide some aditionally useful mechanism.

> The allowed argument range for `day` would be between 1 and `n` with
> `n` the number of days in the month for positive values and between -1
> and `-n` for negative values.

The whole point of being relative is that it acts differently on
different dates. What happens when you do

date(2004, 1, 31) + relativedelta(months=1)

Will it raise an error as well? The current behavior is consistently
designed to get useful results, in addition to what datetime provides.

-- 
Gustavo Niemeyer
http://niemeyer.net



More information about the Python-Dev mailing list