\documentclass[extrafontsizes, 12pt]{memoir}
\usepackage{xcolor}
\usepackage[c4paper,left=1cm, right=1cm,top=1cm, bottom=1cm, landscape]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{multicol}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{math} %needed tikz library
\usepackage{xfp}
\usepackage{ifthen}
\makeatletter
\title{Horaire}\let\Title\@title
\author{A. Einstein} \let\Author\@author
\date{Octobre 2036} \let\Date\@date
\makeatother
% Some colors
\definecolor{Rouge}{HTML}{ffb3ba}
\definecolor{Beige}{HTML}{ffdcb3}
\definecolor{Jaune}{HTML}{ffffb3}
\definecolor{Vert}{HTML}{b3ffb3}
\definecolor{Bleu}{HTML}{b3ccff}
\definecolor{Violet}{HTML}{dfb3ff}
\definecolor{Rose}{HTML}{ffb3ff}
% Days
\def\LU{1}
\def\MA{2}
\def\ME{3}
\def\JE{4}
\def\VE{5}
\def\SA{6}
\def\DI{7}
% Parameters
\def\NJ{7} % Number of days (removes days in command Days is n)
\def\hi{8} % First hour of the day
\def\hf{21} % Last hour of the day
\def\H{18.0}% Height of the timetable
\def\D{30.0}% Width of the timetable
\def\h{1.0} % Height of the header row (days row)
\def\d{2.0} % Width of the first column (times column)
% Days of the timetable. Should contain only the ones displayed
\newcommand\Days{\textbf{Lundi}, \textbf{Mardi}, \textbf{Mercredi}, \textbf{Jeudi}, \textbf{Vendredi}, \textbf{Samedi}, \textbf{Dimanche}}
% Constants
\def\dd{\fpeval{(\D-\d) / \NJ}} % Widht of the columns
\def\Dh{\fpeval{\hf - \hi}} % Total hours per days (Width of columns)
\def\dh{\fpeval{(\H-\h) / \Dh}} % Heigth of an hour (Heigth of rows)
% Event command:
% Input: Name1, Name2, Day, Strating time, Duration, Location, Color
% Output: Draw box in TikZ
\NewDocumentCommand{\event}{ O{Prénom} O{Nom} O{\LU} O{\hi} O{1} O{Lieu} O{Beige}}{
% Transform sexagesimal in decimal
\def\Hdebut{\fpeval{floor(#4)}}; % Starting hour (integer)
\def\Mdebut{\fpeval{round((#4 - \Hdebut )*100)}}; % Starting minute (integer)
\def\Debutdeci{\fpeval{\Hdebut + (#4 - \Hdebut ) / 0.6}}; % Starting time (rational)
\def\Hduration{\fpeval{floor(#5)}}; % Duration hour (integer)
\def\Mduration{\fpeval{round((#5-\Hduration)*100)}}; % Duration minute (integer)
\def\Durationdeci{\fpeval{\Hduration + ((#5-\Hduration) / 0.6)}}; % Duration (rational)
\def\Findeci{\fpeval{\Debutdeci + \Durationdeci}}; % Ending time (rational)
\def\Hfin{\fpeval{floor(\Findeci)}}; % Ending hour (integer)
\def\Mfin{\fpeval{round((\Findeci - \Hfin)*60.0)}}; % Ending minute (integer)
\def\x{\fpeval{\d + ( #3 - 1 ) * \dd}}; % Columns position (start)
\def\xx{\fpeval{\d + #3 * \dd}}; % Columns position (end)
\def\yy{\fpeval{(\hf - \Debutdeci ) * \dh}}; % Row position (start)
\def\y{\fpeval{\yy - \Durationdeci * \dh}}; % Row position (end)
% Display double zero (i.e. 14:00 instead of 14:0 )
\ifthenelse{\equal{\Mdebut}{0}}
{
\ifthenelse{\equal{\Mfin}{0}}
{\filldraw [fill= #7, draw=black] (\x, \y) rectangle (\xx, \yy) node[pos=.5, text width=5cm, align=center] {\textbf{#1 #2} \linebreak \textit{#6} \linebreak \Hdebut :00\,-\,\Hfin h00 };}
{\filldraw [fill= #7, draw=black] (\x, \y) rectangle (\xx, \yy) node[pos=.5, text width=5cm, align=center] {\textbf{#1 #2} \linebreak \textit{#6} \linebreak \Hdebut :00\,-\,\Hfin :\Mfin };}
}
{
\ifthenelse{\equal{\Mfin}{0}}
{\filldraw [fill= #7, draw=black] (\x, \y) rectangle (\xx, \yy) node[pos=.5, text width=5cm, align=center] {\textbf{#1 #2} \linebreak \textit{#6} \linebreak \Hdebut :\Mdebut \,-\,\Hfin :00 };}
{\filldraw [fill= #7, draw=black] (\x, \y) rectangle (\xx, \yy) node[pos=.5, text width=5cm, align=center] {\textbf{#1 #2} \linebreak \textit{#6} \linebreak \Hdebut :\Mdebut \,-\,\Hfin :\Mfin };}
}
}
\begin{document}
\pagenumbering{gobble}
\centering
{\huge%
\Title \linebreak \Large \Author \linebreak \normalsize Comment
}
\vfill
\begin{tikzpicture}
\draw [draw=black] (0.0,0.0) rectangle (30.0,18.0);
\def\fin{\fpeval{\Dh-1}};
\foreach \i in {1,...,\fin}{
\def\y{\fpeval{\i*\dh}} ;
\def\heure{\fpeval{(\hf-\i)}};
\def\x{\fpeval{\d/2.0}}
\node at (\x,\y) {\heure: 00};
\draw[dashed](\d, \y)--(\D, \y);
};
\foreach \j [count=\i] in \Days{
\def\y{\fpeval{\H-0.5*\h}};
\def\x{\fpeval{2*\d + (\i - 1) * \dd}};
\node at (\x , \y) {\j};
};
\event[Adar][Rigo][\VE][16][1.30][Moon];
\event[Rada][Ogir][\LU][17.45][1.40][Mars];
\event[Swimming][][\MA][17.30][2.30][Venus];
\event[Teaching:][Math007][\ME][15.10][3.45][Earth][Rouge];
\event[Default]
\event[Tutoring:][\LaTeX][\JE][12.30][1.45][][Vert];
\event[Quiditch:][Final][\SA][8][10][Poudlard][Violet];
\end{tikzpicture}
\vfill
\end{document}