#!/bin/sh set -eu _parse_ics=parse_ics if ! command -v "$_parse_ics" >/dev/null 2>/dev/null; then BOOKSQL_PATH="${BOOKSQL_PATH:-"$(dirname -- "$(dirname -- "$(readlink -f "$0")")")"}" _parse_ics="$BOOKSQL_PATH/bin/parse_ics" fi # Bank holidays, where libraries are closed curl -s https://etalab.github.io/jours-feries-france-data/ics/jours_feries_metropole.ics | "$_parse_ics" | jq -r '._components[].dtstart[][]' | sed -E 's/^([0-9]{4})([[:digit:]]{2})([[:digit:]]{2})$/\1-\2-\3/; s/.*/INSERT OR REPLACE INTO holidays (start, end, closed) VALUES ('"'"'&'"'"', '"'"'&'"'"', TRUE);/' # School holidays, where libraries are still open, sometimes under different schedules curl -s 'https://data.education.gouv.fr/api/explore/v2.1/catalog/datasets/fr-en-calendrier-scolaire/exports/ical?lang=fr&timezone=Europe%2FParis' | "$_parse_ics" | jq -r '[._components[] | select(._type == "VEVENT").description[][] | gsub("\\\\n"; "\n")]|join("\n\n")' | recsel -e 'population != "Enseignants" && location = "Grenoble" && start_date != end_date' | recfmt "INSERT OR REPLACE INTO holidays (start, end, closed) SELECT DATE(SUBSTR('{{start_date}}', 0, 11), '1 days'), SUBSTR('{{end_date}}', 0, 11), FALSE; "