This is an example exercise to be solved by a new user to the library using only the dateutil documentation, per #663.
Excercise: Next Monday meeting
A team has a meeting at 10 AM every Monday and wants a function that tells them, given a datetime.datetime object, what is the date and time of the next Monday meeting?
Test Cases
from datetime import datetime
from dateutil import tz
NEXT_MONDAY_CASES = [
(datetime(2018, 4, 11, 14, 30, 15, 123456),
datetime(2018, 4, 16, 10, 0)),
(datetime(2018, 4, 16, 10, 0),
datetime(2018, 4, 16, 10, 0)),
(datetime(2018, 4, 16, 10, 30),
datetime(2018, 4, 23, 10, 0)),
(datetime(2018, 4, 14, 9, 30, tzinfo=tz.gettz('America/New_York')),
datetime(2018, 4, 16, 10, 0, tzinfo=tz.gettz('America/New_York'))),
]
def test_next_monday_1(f):
for dt_in, dt_out in NEXT_MONDAY_CASES:
assert f(dt_in) == dt_out
To Do
This is an example exercise to be solved by a new user to the library using only the dateutil documentation, per #663.
Excercise: Next Monday meeting
Test Cases
To Do
relativedeltabased on this