I am trying to get a datetime seven days prior to another date.
So I am doing in the console:
import datetime
from dateutil.relativedelta import relativedelta
dt = datetime.date(2014, 10, 18)
dt_minus_one_week = datetime.date(2014, 10, 18) - relativedelta(days=7)
The result is, as expected, datetime.date(2014, 10, 11)
. However, I am running a webservice (using eve, but I think that this is unimportant) application for a long time, and then when I invoke the method to get the one week older date, I get datetime.date(2014, 10, 10)
. The code is exactly the same as above.
If I restart the app, the date is what I expected it to be. Why is this happening? Is relativedelta nondeterministic? Is there any way to "reset" it so I can get the right value again?