#### advdate and skip dates based on holidays

##### Replies

User

( 4 months ago )

I am following up from the question here. My main purpose is to write a syllabus and schedule for a class that meets only on certain days of the week accounting for some holidays. In this question, I have asked about how to skip weekdays that are not M or W.

Now I want to skip to the next class day if the current class day falls on a holiday. Say I have a list of holidays {13/1/2014, 22/1/2014}. I want to check if mydate or today in the following code falls on any one of those days and skip to the next classday (M or W) as the case may be. For example, I want third class to fall on 15/1 and sixth calss to fall on 27/1. I am OK if it is not perfectly generalisable (i.e. no need to check for the year and I can make sure that the holidays listed in the arrary are either a M or W).

 \documentclass{article}
\usepackage[ddmmyyyy]{datetime}% http://ctan.org/pkg/datetime

\newdateformat{syldate}{\THEMONTH/\THEDAY/\THEYEAR}%(\shortdayofweekname%{\THEDAY}{\THEMONTH}  {\THEYEAR})}

\newsavebox{\MONDAY}\savebox{\MONDAY}{Mon}% Mon

\makeatletter
\newcommand{\cleardate}[1]{%
\expandafter\let\csname date@#1@d\endcsname\relax% Clear day
\expandafter\let\csname date@#1@m\endcsname\relax% Clear month
\expandafter\let\csname date@#1@y\endcsname\relax% Clear year
}
\makeatother

\newcommand{\class}[1]{%
\cleardate{mydate}% Clear date
\newdate{mydate}{\the\day}{\the\month}{\the\year}% Store date
\setbox1=\hbox{\shortdayofweekname{\getdateday{mydate}}{\getdatemonth{mydate}}{\getdateyear{mydate}}}%
\ifdim\wd1=\wd\MONDAY
\else
\fi%
}

\SetDate[06/01/2014]

\begin{document}

\class{First class}
\class{Second class}
\class{Third class}
\class{Fourth class}
\class{Fifth class}
\class{Sixth class}
\class{Seventh class}

\end{document}

I was thinking of using \foreach but that does not work as foreach will skip for each element of the list. I thought \AdvanceDate[0] would work but it does not seem to store the \today after exiting the loop. Any help is appreciated.

Ra
04-Sep-2019

2 Replies

Ra
05-Sep-2019

2 Replies

11-Sep-2019

0 Replies