I want to make a table where I describe every week some facts, in two specific days. These days are fixed in the table, but they are selected arbitrarily. I would like to print the dates of each date automatically.
In the next MWE almost make all the work, but it only works for \today, I don't know how how change the start date, something like \setstartdate{}.
This code implies some calculations with dates, so I took some code from
Insert relative date and time specifications?
but there are some problems with the algorithm.
How can I fix the problem? or how can I improve it with another code?
This is the MWE
\documentclass{article}
\usepackage{xstring,datenumber,advdate,datetime,pgf,calc}
\usepackage{longtable}
\newcounter{dateOffset}%
\newcommand*{\SetDateOffsetForNext}[1]{%
\pgfmathsetcounter{dateOffset}{7-int(\the\value{datedayname})}% Initialize
\IfStrEqCase{#1}{%
{mon}{\pgfmathsetcounter{dateOffset}{int(mod(\the\value{dateOffset}+1,7))}}%
{tue}{\pgfmathsetcounter{dateOffset}{int(mod(\the\value{dateOffset}+2,7))}}%
{wed}{\pgfmathsetcounter{dateOffset}{int(mod(\the\value{dateOffset}+3,7))}}%
{thu}{\pgfmathsetcounter{dateOffset}{int(mod(\the\value{dateOffset}+4,7))}}%
{fri}{\pgfmathsetcounter{dateOffset}{int(mod(\the\value{dateOffset}+5,7))}}%
{sat}{\pgfmathsetcounter{dateOffset}{int(mod(\the\value{dateOffset}+6,7))}}%
{sun}{\pgfmathsetcounter{dateOffset}{int(mod(\the\value{dateOffset}+7,7))}}%
}[\PackageError{\SetDateOffsetForNext}{Do not know "#1" as day of week}{}]%
\IfEq{\the\value{dateOffset}}{0}{\pgfmathsetcounter{dateOffset}{0}}{}%
}%
\newcommand{\dayone}{mon}
\newcommand{\daytwo}{wed}
\newcounter{weeknumber}
\newcounter{sessionnumber}
\newcommand{\rowdayone}[1]{\addtocounter{weeknumber}{1}\addtocounter{sessionnumber}{1}%
\theweeknumber{} -- \thesessionnumber &
\SetDateOffsetForNext{\dayone}% Determine date offset
\addtocounter{dateOffset}{7*(\theweeknumber-1)}%
\AdvanceDate[\thedateOffset]% Advance to specified day
\today% Print specified date
%\AdvanceDate[-\thedateOffset]% Restore current day
& #1}
\newcommand{\rowdaytwo}[1]{\addtocounter{sessionnumber}{1}%
\theweeknumber{} -- \thesessionnumber &
\SetDateOffsetForNext{\daytwo}% Determine date offset
\addtocounter{dateOffset}{7*(\theweeknumber-1)}%
\AdvanceDate[\thedateOffset]% Advance to specified day
\today% Print specified date
%\AdvanceDate[-\thedateOffset]% Restore current day
& #1}
\newdateformat{short}{%
\twodigit{\THEDAY}/\twodigit{\THEMONTH}%
}
\begin{document}\short
%\SetDate[11/01/2015]
\begin{longtable}{|c|c|c|}
\rowdayone{description day 1 of week 1} \\
\rowdaytwo{description day 2 of week 1} \\
\rowdayone{description day 1 of week 2} \\
\rowdaytwo{description day 2 of week 2} \\
\rowdayone{description day 1 of week 3}
\end{longtable}
Last update \today
\end{document}
