%\documentclass[tikz]{standalone}% Does not support leap years.
\documentclass[a4paper]{article}% Does not support leap years.
\usepackage{geometry}
 \geometry{
      a4paper,
      left=0mm,
      top=0mm,
      bottom=0mm,
      right=0mm,
  }



%% Load needed packages
\usepackage{lmodern}
\usepackage{tikz}
    \usetikzlibrary{positioning}
\usepackage[T1]{fontenc}


\usepackage{ifthen}
\usepackage{xifthen}% provides \isempty test

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%node font
\tikzset{year/.style={anchor=north west, minimum height = 5mm}}
\tikzset{dayname/.style={anchor=north west, font=\large}}
\tikzset{daynumber/.style={anchor=north west, font=\large\bfseries}}
\tikzset{dayspecialname/.style={font=\small\bfseries,anchor=north west, align=left, text width=5.5cm }}
\tikzset{dayspecial/.style={color=blue!50!green}}
\tikzset{month/.style={anchor=north west, font=\large}}
\tikzset{kw/.style={anchor=north west, font=\large}}

\newcommand{\monday}[0]{Montag}
\newcommand{\tuesday}[0]{Dienstag}
\newcommand{\wednesday}[0]{Mittwoch}
\newcommand{\thursday}[0]{Donnerstag}
\newcommand{\friday}[0]{Freitag}
\newcommand{\saturday}[0]{Samstag}
\newcommand{\sunday}[0]{Sonntag}

\newcommand{\drawlinewidth}[0]{0.5mm}

\newcommand{\useclock}{true}

\newcommand{\daylines}[5]{
    \foreach \i in {#3, #4, ..., #5}{%
        \draw [black!30!white,line width=\drawlinewidth] (#1,\i) -- (#2,\i);
    }

}

\newcommand{\taskbox}[5]{
    % horizontal lines
    \foreach \i in {#3, #4, ..., #5}{%
        \draw [black!30!white, line width=\drawlinewidth] (#1,\i) -- (#2,\i);
    }

    % last vertical
    \draw [gray, line width=\drawlinewidth] (#2,   #3) -- (#2,#5);

    % fist 3 vertical
    \foreach \i in {0, 1, ..., 3}{%

        \draw [black!30!white, line width=\drawlinewidth] (#1+\i,   #3) -- (#1+\i,#5);
    }

}

\newcommand{\clock}[2]
{
	\node (A) at (#1,#2) {};
	\filldraw [fill=gray!10!white] (A) circle [radius=2.4];
	\filldraw [fill=gray!30!white] (A) circle [radius=2.2];
	\foreach \angle in {0,7.5,...,360}
	{
		\draw[line width=0.5pt] (A.center)+(\angle:2.2) -- (A.center);
	}
	\foreach \angle in {0,15,...,360}
	{
		\draw[line width=2pt] (A.center)+(\angle:2.2) -- 		(A.center);
	}
	\filldraw [fill=white] (A) circle [radius=2];
	\filldraw [fill=white] (A) circle [radius=1.5];
	\filldraw [fill=black] (A) circle [radius=0.05];
	
	\foreach \angle / \label in
	{0/3, 30/4, 60/5, 90/6, 120/7, 150/8, 180/9,
		210/10, 240/11, 270/12, 300/1, 330/2}
	{
		\draw (A)+(\angle:1.73) node{\textsf{\label}};
		\draw[line width=0.1pt] (A.center)+(\angle:1.5) -- 		(A.center);
	}
}

\newcommand{\printweek}[7]{
	% KW
	%monday date of month
	%monday special text
	%tuesday date of month
	%tuesday special text
	%Wednesday date of month
	%Wednesday special text
	
	\begin{tikzpicture}[xscale = 1.08,
		yscale=-1,% CAUTION: axis direction reversed!
		]
		
		\node at (0,-0.3) {};
		\node at (0,0.3) [kw] {#1}; %prints kw
		\node at (1.25,0.3) [month] {\month}; %prints month
		\node at (3,0.3) [year]  {\year};    %prints year
		
		
		\ifthenelse{\equal{true}{\useclock}} {	
			\daylines{0}{5.9}{3}{4}{5}
			\clock{3}{7.6}
			\daylines{0}{5.9}{11}{12}{15}
			
			\daylines{ 6}{11.9}{3}{4}{5}
			\clock{9}{7.6}
			\daylines{ 6}{11.9}{11}{12}{15}
			
			\daylines{ 12}{17.9}{3}{4}{5}
			\clock{15}{7.6}
			\daylines{ 6}{17.9}{11}{12}{15}
		}{
			\daylines{ 0}{ 5.9}{3}{4}{15}
			\daylines{ 6}{11.9}{3}{4}{15}
			\daylines{12}{17.9}{3}{4}{15}
		}
		
		
		\ifthenelse{\isempty{#3}} {
			\node at (0,  1.0) [daynumber] {#2};
			\node at (1.5,1.0) [dayname] {\monday};
		} {
			\node at (0,  1.5) [dayspecial,dayspecialname] {#3};
			\node at (0,  1.0) [dayspecial,daynumber] {#2};
			\node at (1.5,1.0) [dayspecial,dayname] {\monday};
		}
		
		\ifthenelse{\isempty{#5}} {
			\node at (6,  1.0) [daynumber] {#4};
			\node at (7.5,1.0) [dayname] {\tuesday};
		} {
			\node at (6,  1.5) [dayspecial, dayspecialname] {#5};
			\node at (6,  1.0) [dayspecial, daynumber] {#4};
			\node at (7.5,1.0) [dayspecial, dayname] {\tuesday};
		}
		
		\ifthenelse{\isempty{#7}} {
			\node at (12,  1.0) [daynumber] {#6};
			\node at (13.5,1.0) [dayname] {\wednesday};
		} {
			\node at (12,  1.5) [dayspecial, dayspecialname] {#7};
			\node at (12,  1.0) [dayspecial, daynumber] {#6};
			\node at (13.5,1.0) [dayspecial, dayname] {\wednesday};
		}
		
		\taskbox{0}{18}{15.5}{16.5}{28.5}
		
		
		\node at (6,  15.25) [daynumber] {};
		
	\end{tikzpicture}%
}


\newcommand{\printweekend}[9]{
	%KW
	%thursday date of month
	%thursday special text
	%Friday date of month
	%Friday special text
	%Saturday date of month
	%Saturday special text
	%Sunday date of month
	%Sunday special text
	
	\begin{tikzpicture}[
		xscale = 1.08,
		yscale=-1,  % CAUTION: axis direction reversed!
		]
		
		\node at (0,-0.3) {};
		\node at (18,0.3) [kw, anchor=east] {#1}; %prints month name
		\node at (16.75,0.3) [month, anchor=east] {\month}; %prints month name
		\node at (15,0.3) [year, anchor=east]  {\year};    %prints year number
		
		\ifthenelse{\isempty{#3}} {
			\node at (0,  1.0) [daynumber] {#2};
			\node at (0.5,1.0) [dayname] {\thursday};
		} {
			\node at (0,  1.5) [dayspecial, dayspecialname] {#3};
			\node at (0,  1.0) [dayspecial, daynumber] {#2};
			\node at (0.5,1.0) [dayspecial, dayname] {\thursday};
		}
		
		\ifthenelse{\equal{true}{\useclock}} {	
			\daylines{0}{5.9}{3}{4}{5}
			\clock{3}{7.6}
			\daylines{0}{5.9}{11}{12}{15}
			
			\daylines{ 6}{11.9}{3}{4}{5}
			\clock{9}{7.6}
			\daylines{ 6}{11.9}{11}{12}{15}
			
			\daylines{12}{17.9}{3}{4}{5}
			\clock{15}{7.6}
			\daylines{12}{17.9}{11}{12}{15}
			
			\daylines{12}{17.9}{17.5}{18.5}{19.5}
			\clock{15}{22.1}
			\daylines{12}{17.9}{25.5}{26.5}{28.5}
		}{
			\daylines{ 0}{ 5.9}{3}{4}{15}
			\daylines{ 6}{11.9}{3}{4}{15}
			\daylines{12}{17.9}{3}{4}{15}
			\daylines{12}{17.9}{17.5}{18.5}{28.5}
		}
		
		\ifthenelse{\isempty{#5}} {
			\node at (6,  1.0) [daynumber] {#4};
			\node at (6.5,1.0) [dayname] {\friday};
		} {%
			\node at (6,  1.0) [dayspecial, daynumber] {#4};
			\node at (6.5,1.0) [dayspecial, dayname] {\friday};
			\node at (6,  1.5) [dayspecial, dayspecialname] {#5};
		}%
		
		\ifthenelse{\isempty{#7}} {
			\node at (12,  1.0) [daynumber,color=orange] {#6};
			\node at (12.5,1.0) [dayname,color=orange] {\saturday};
		} {%
			\node at (12,  1.5) [dayspecial, dayspecialname] {#7};
			\node at (12,  1.0) [dayspecial, daynumber] {#6};
			\node at (12.5,1.0) [dayspecial, dayname] {\saturday};
		}%
		
		\ifthenelse{\isempty{#9}} {
			\node at (12,  15.7) [daynumber,color=red] {#8};
			\node at (12.5,15.7) [dayname,color=red] {\sunday};
		} {%
			\node at (12,  15.7) [dayspecial, daynumber] {#8};
			\node at (12,  16.2) [dayspecial, dayspecialname] {#9};
			\node at (13.5,15.7) [dayspecial, dayname] {\sunday};
		}%
		
		\taskbox{0}{11.9}{15.5}{16.5}{28.5}
		
		
		\node at (6,  15.25) [daynumber] {};
	\end{tikzpicture}%
}
