The "mday" parameter can be passed more than the number of days in a month. You can use this parameter to pass the "number of days since the start of the year". Strangely the "ydays" parameter doesn't do anything. You can also use strftime and mktime to calculate the date of "1 week ago". You can pass the current "epoch" timestamp in the "secs" parameter.
So this function is very flexible and robust.
Ciaran