Skip to content

Instantly share code, notes, and snippets.

@christopheredsall
Created October 8, 2019 17:01
Show Gist options
  • Save christopheredsall/17f119fd277a1cf4c17f142c585d9ffd to your computer and use it in GitHub Desktop.
Save christopheredsall/17f119fd277a1cf4c17f142c585d9ffd to your computer and use it in GitHub Desktop.
Rota.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Rota.ipynb",
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/christopheredsall/17f119fd277a1cf4c17f142c585d9ffd/rota.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "zjH7W0JIM2Vf",
"colab_type": "code",
"outputId": "a4400e2b-3ff4-437a-d7f6-b27a89bf77c6",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 221
}
},
"source": [
"from datetime import date, timedelta\n",
"import calendar\n",
"\n",
"sites = ['Bath',\n",
" 'Bristol',\n",
" 'Cardiff',\n",
" 'Exeter']\n",
"offset = 1 # start with Bristol\n",
"start_date = date(2019,10,7)\n",
"weeks_to_schedule = 12\n",
"format = '%a %d %b'\n",
"for week in range(weeks_to_schedule):\n",
" monday = start_date + timedelta(days=(week * 7))\n",
" friday = monday + timedelta(days=4)\n",
" print(monday.strftime(format), \"--\", friday.strftime(format), \" \",\n",
" sites[(week + offset ) % 4])"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"Mon 07 Oct -- Fri 11 Oct Bristol\n",
"Mon 14 Oct -- Fri 18 Oct Cardiff\n",
"Mon 21 Oct -- Fri 25 Oct Exeter\n",
"Mon 28 Oct -- Fri 01 Nov Bath\n",
"Mon 04 Nov -- Fri 08 Nov Bristol\n",
"Mon 11 Nov -- Fri 15 Nov Cardiff\n",
"Mon 18 Nov -- Fri 22 Nov Exeter\n",
"Mon 25 Nov -- Fri 29 Nov Bath\n",
"Mon 02 Dec -- Fri 06 Dec Bristol\n",
"Mon 09 Dec -- Fri 13 Dec Cardiff\n",
"Mon 16 Dec -- Fri 20 Dec Exeter\n",
"Mon 23 Dec -- Fri 27 Dec Bath\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "0D2mjJc-Ojdt",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": 0,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment