%\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{ifthen}
\usepackage{xifthen}% provides \isempty test

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%node font
\tikzset{year/.style={anchor=west, minimum height = 5mm}}
\tikzset{dayname/.style={anchor=west, font=\large}}
\tikzset{daynumber/.style={anchor=west, font=\large\bfseries}}
\tikzset{dayspecialname/.style={font=\small\bfseries,anchor=west, align=left, text width=5.5cm }}
\tikzset{dayspecial/.style={color=blue!50!green}}
\tikzset{month/.style={anchor=west, font=\large}}
\tikzset{kw/.style={anchor=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{\daylines}[5]{
    \foreach \i in {#3, #4, ..., #5}{%
        \draw [black!30!white, thin] (#1,\i) -- (#2,\i);
    }

}

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

    % last vertical
    \draw [gray, thin,dotted] (#2,   #3) -- (#2,#5);

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

        \draw [black!30!white, thin,dotted] (#1+\i,   #3) -- (#1+\i,#5);
    }

}

\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) [year]  {\year};    %prints year number
    \node at (1,0) [month] {\month}; %prints month name
    \node at (4,0) [kw] {#1}; %prints month name


    \ifthenelse{\isempty{#3}} {
        \node at (0,  0.7) [daynumber] {#2};
        \node at (1.5,0.7) [dayname] {\monday};
        \daylines{0}{5.9}{1}{1.5}{15}
    } {
        \node at (0,  0.7) [dayspecial,daynumber] {#2};
        \node at (0,  1.2) [dayspecial,dayspecialname] {#3};
        \node at (1.5,0.7) [dayspecial,dayname] {\monday};
        \daylines{0}{5.9}{2}{2.5}{15}
    }

    \ifthenelse{\isempty{#5}} {
        \node at (6,  0.7) [daynumber] {#4};
        \node at (7.5,0.7) [dayname] {\tuesday};
        \daylines{6}{11.9}{1}{1.5}{15}
    } {
        \node at (6,  0.7) [dayspecial,daynumber] {#4};
        \node at (6,  1.0) [dayspecial,dayspecialname] {#5};
        \node at (7.5,0.7) [dayspecial,dayname] {\tuesday};
        \daylines{6}{11.9}{2}{2.5}{15}
    }

    \ifthenelse{\isempty{#7}} {
        \node at (12,  0.7) [daynumber] {#6};
        \node at (13.5,0.7) [dayname] {\wednesday};
        \daylines{12}{17.9}{1}{1.5}{15}
    } {
        \node at (12,  0.7) [dayspecial,daynumber] {#6};
        \node at (12,  1.0) [dayspecial,dayspecialname] {#7};
        \node at (13.5,0.7) [dayspecial,dayname] {\wednesday};
        \daylines{12}{17.9}{2}{2.5}{15}
    }

    \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) [year, anchor=east]  {\year};    %prints year number
    \node at (17,0) [month, anchor=east] {\month}; %prints month name
    \node at (15,0) [kw, anchor=east] {#1}; %prints month name

    \ifthenelse{\isempty{#3}} {
        \node at (0,  0.5) [daynumber] {#2};
        \node at (0.5,0.5) [dayname] {\thursday};
        \daylines{0}{5.9}{1}{1.5}{15}
    } {
        \node at (0,  0.5) [dayspecial,daynumber] {#2};
        \node at (0,  1.0) [dayspecial,dayspecialname] {#3};
        \node at (0.5,0.5) [dayspecial,dayname] {\thursday};
        \daylines{0}{5.9}{2}{2.5}{15}
    }


    \ifthenelse{\isempty{#5}} {
        \node at (6,  0.5) [daynumber] {#4};
        \node at (6.5,0.5) [dayname] {\friday};
        \daylines{6}{11.9}{1}{1.5}{15}
    } {%
        \node at (6,  0.5) [dayspecial,daynumber] {#4};
        \node at (6,  1.0) [dayspecial,dayspecialname] {#5};
        \node at (6.5,0.5) [dayspecial,dayname] {\friday};
        \daylines{6}{11.9}{2}{2.5}{15}
    }%

    \ifthenelse{\isempty{#7}} {
        \node at (12,  0.5) [daynumber,color=orange] {#6};
        \node at (12.5,0.5) [dayname,color=orange] {\saturday};
        \daylines{12}{17.9}{1}{1.5}{15}
    } {%
        \node at (12,  0.5) [dayspecial,daynumber] {#6};
        \node at (12,  1.0) [dayspecial,dayspecialname] {#7};
        \node at (12.5,0.5) [dayspecial,dayname] {\saturday};
        \daylines{12}{17.9}{2}{2.5}{15}
    }%

    \ifthenelse{\isempty{#9}} {
        \node at (12,  15.7) [daynumber,color=red] {#8};
        \node at (12.5,15.7) [dayname,color=red] {\sunday};
        \daylines{12}{17.9}{16}{16.5}{28.5}
    } {%
        \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};
        \daylines{12}{17.9}{17}{17.5}{28.5}
    }%

    \taskbox{0}{11.9}{15.5}{16.5}{28.5}


    \node at (6,  15.25) [daynumber] {};
    \end{tikzpicture}%
}

