The relativedelta type is based on the specification of the excelent work done by M.-A. Lemburg in his mx.DateTime extension. However, notice that this type does NOT implement the same algorithm as his work. Do NOT expect it to behave like mx.DateTime’s counterpart.
There’s two different ways to build a relativedelta instance. The first one is passing it two date/datetime classes:
relativedelta(datetime1, datetime2)
And the other way is to use the following keyword arguments:
- year, month, day, hour, minute, second, microsecond:
- Absolute information.
- years, months, weeks, days, hours, minutes, seconds, microseconds:
- Relative information, may be negative.
- weekday:
- One of the weekday instances (MO, TU, etc). These instances may receive a parameter N, specifying the Nth weekday, which could be positive or negative (like MO(+1) or MO(-2). Not specifying it is the same as specifying +1. You can also use an integer, where 0=MO.
- leapdays:
- Will add given days to the date found, if year is a leap year, and the date found is post 28 of february.
- yearday, nlyearday:
- Set the yearday or the non-leap year day (jump leap days). These are converted to day/month/leapdays information.
Here is the behavior of operations with relativedelta:
Methods
__init__([dt1, dt2, years, months, days, ...]) |