aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Ganssle <paul@ganssle.io>2018-06-08 07:26:25 +0100
committerPaul Ganssle <paul@ganssle.io>2018-06-08 07:26:52 +0100
commita5c248b6a1e641cbd7c893324082d41af4ec9105 (patch)
tree75fd980169b4688aeaebde1d782739796d74074f
parent404af91dce1e44879ee38dc7e3038b0f85f7afa6 (diff)
downloaddateutil-a5c248b6a1e641cbd7c893324082d41af4ec9105.tar.gz
Add next monday morning exercise
-rw-r--r--docs/exercises/index.rst50
1 files changed, 50 insertions, 0 deletions
diff --git a/docs/exercises/index.rst b/docs/exercises/index.rst
index d43337d..36dca2b 100644
--- a/docs/exercises/index.rst
+++ b/docs/exercises/index.rst
@@ -62,6 +62,56 @@ To solve this exercise, copy-paste this script into a document, change anything
test_mlk_day()
print('Success!')
+.. raw:: html
+
+ </details>
+
+
+
+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? This is probably best accomplished using a `relativedelta <../relativedelta.html>`_.
+
+**Test Script**
+
+To solve this exercise, copy-paste this script into a document, change anything between the ``--- YOUR CODE ---`` comment blocks.
+
+.. raw:: html
+
+ <details>
+
+
+.. code-block:: python3
+
+ # --------- YOUR CODE -------------- #
+ from dateutil import relativedelta
+
+ def next_monday(dt):
+ <<YOUR CODE HERE>>
+
+ # ---------------------------------- #
+
+ 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():
+ for dt_in, dt_out in NEXT_MONDAY_CASES:
+ assert next_monday(dt_in) == dt_out
+
+ if __name__ == "__main__":
+ test_next_monday_1()
.. raw:: html