+horaires.sh
This commit is contained in:
parent
c06e920b5b
commit
f1bfff1d71
2 changed files with 75 additions and 0 deletions
13
horaires/horaires.csv
Normal file
13
horaires/horaires.csv
Normal file
|
@ -0,0 +1,13 @@
|
|||
Jour,Semaine,Horaire
|
||||
Lundi,B,09:00-15:00
|
||||
Mardi,B,07:00-12:00 12:30-17:00
|
||||
Mercredi,B,14:00-17:00
|
||||
Jeudi,B,07:00-13:00
|
||||
Vendredi,B,07:00-12:00 14:00-18:00
|
||||
Samedi,B,08:00-12:00
|
||||
Lundi,A,09:00-14:00
|
||||
Mardi,A,07:00-12:00 12:30-17:00
|
||||
Mercredi,A,12:30-18:00
|
||||
Jeudi,A,07:00-12:00 13:30-17:00
|
||||
Vendredi,A,08:30-12:30 13:30-18:00
|
||||
|
|
62
horaires/horaires.sh
Executable file
62
horaires/horaires.sh
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Fichier CSV contenant les horaires
|
||||
CSV_FILE="horaires.csv"
|
||||
|
||||
# Traduction manuelle des jours (anglais -> français)
|
||||
declare -A JOURS_EN_FR=(
|
||||
["Monday"]="Lundi"
|
||||
["Tuesday"]="Mardi"
|
||||
["Wednesday"]="Mercredi"
|
||||
["Thursday"]="Jeudi"
|
||||
["Friday"]="Vendredi"
|
||||
["Saturday"]="Samedi"
|
||||
["Sunday"]="Dimanche"
|
||||
)
|
||||
|
||||
# Liste des jours en français pour correspondre aux numéros (1 = Lundi, ...)
|
||||
JOURS=("Lundi" "Mardi" "Mercredi" "Jeudi" "Vendredi" "Samedi" "Dimanche")
|
||||
|
||||
# Si l'argument est un chiffre (1 ou 2), on calcule le jour futur
|
||||
if [[ "$1" =~ ^[1-2]$ ]]; then
|
||||
# Calculer la date future
|
||||
DATE_FUTURE=$(date -d "+$1 day" +"%A") # Ex: "Sunday"
|
||||
JOUR=${JOURS_EN_FR[$DATE_FUTURE]} # Traduction
|
||||
|
||||
# Vérifier si on change de semaine
|
||||
SEMAINE_NUM=$(date -d "+$1 day" +"%V")
|
||||
if ((SEMAINE_NUM % 2 == 0)); then
|
||||
SEMAINE="A"
|
||||
else
|
||||
SEMAINE="B"
|
||||
fi
|
||||
|
||||
# Sinon, si l'argument est du type "3B"
|
||||
elif [[ "$1" =~ ^[1-7][AB]$ ]]; then
|
||||
JOUR_INDEX=${1:0:1} # Numéro du jour (1 = Lundi, ..., 7 = Dimanche)
|
||||
SEMAINE=${1:1:1} # A ou B
|
||||
|
||||
JOUR=${JOURS[$((JOUR_INDEX - 1))]}
|
||||
|
||||
# Sinon, on prend le jour actuel
|
||||
else
|
||||
JOUR_ANGLAIS=$(date +"%A")
|
||||
JOUR=${JOURS_EN_FR[$JOUR_ANGLAIS]} # Traduction
|
||||
SEMAINE_NUM=$(date +"%V")
|
||||
if ((SEMAINE_NUM % 2 == 0)); then
|
||||
SEMAINE="A"
|
||||
else
|
||||
SEMAINE="B"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Lire et filtrer le CSV
|
||||
HORAIRE=$(awk -F, -v jour="$JOUR" -v semaine="$SEMAINE" '$1 == jour && $2 == semaine {print $3}' "$CSV_FILE")
|
||||
|
||||
# Afficher le résultat
|
||||
if [[ -n "$HORAIRE" ]]; then
|
||||
echo "Horaires de $JOUR (semaine $SEMAINE) : $HORAIRE"
|
||||
else
|
||||
echo "Aucun horaire trouvé pour $JOUR (semaine $SEMAINE)."
|
||||
fi
|
||||
|
Loading…
Reference in a new issue