6e35d9e064
Signed-off-by: Marc Ahlgrim <marc@onemarcfifty.com>
15 lines
477 B
Python
15 lines
477 B
Python
import datetime
|
|
|
|
# ################################################
|
|
# Returns the date of the next given weekday after
|
|
# the given date. For example, the date of next Monday.
|
|
# NB: if it IS the day we're looking for, this returns 0.
|
|
# consider then doing onDay(foo, day + 1).
|
|
# Monday=0, Tuesday=1 .... Sunday=6
|
|
# ################################################
|
|
|
|
def onDay(date, day):
|
|
days = (day - date.weekday() + 7) % 7
|
|
return date + datetime.timedelta(days=days)
|
|
|