[Python-Dev] dateutil
Gustavo Niemeyer
niemeyer at conectiva.com
Mon Mar 15 09:27:59 EST 2004
Hello Greg!
> Isn't the name "relativedelta" somewhat superfluouslyredundant?
> The word "delta" already implies something relative.
IMO, no. The "relative" here means that the operation made is dependent
on what you apply it, and not a "fixed" delta as timedelta would do.
Applying the same delta on two different dates might return the same
result, for example.
> (It's also ratherhardtoread.)
Ok, I'll rename it to "relativetimedelta". ;-))
> > >>> d
> > datetime.datetime(2004, 4, 4, 0, 0)
> > >>> d+relativedelta(month=1)
> > datetime.datetime(2004, 1, 4, 0, 0)
>
> So a relativedelta can affect things in a way that's not
> relative at all? That sounds *very* confusing.
It makes sense in this context. Please, have a look at the examples
in the documentation. Tim is right about this being based on
mxDateTime.
> Wouldn't it be better if relativedelta confined itself to
> relative things only, and provide some other way of
> absolutely setting fields of a date?
I don't think so, but I'm of course open to suggestions.
> > MO(0) shouldn't be used as it makes no sense, but is the same
> > as MO(+1) which is the same as MO(1).
>
> So there is a hole at 0. Something about that smells wrong.
If you discover what, please tell me. :-)
> > The expected type [of leapdays] is an integer. This is mainly used
> > to implement nlyearday.
>
> Would a value other than 0 or 1 ever make sense for this? I'm
> having a hard time imagining how it could -- but maybe my imagination
> isn't twisted enough...
The only used values now are 0 and -1, for nlyearday. This parameter is
indeed confusing, as it doesn't seem useful by itself. I'll probably
remove it from the documentation.
> > >>> date(2000,2,29)+relativedelta(months=+12)
> > datetime.date(2001, 2, 28)
>
> I think the OP's question was what happens if you do
>
> for i in range(12):
> d += relativedelta(months=+1)
I answered that just below the above example. It lands on the same
date.
Thanks for exposing your ideas!
--
Gustavo Niemeyer
http://niemeyer.net
More information about the Python-Dev
mailing list