advdate and skip dates based on holidays

Course Queries Syllabus Queries 3 years ago

4.46K 1 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years 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 holihttps://forum.tuteehub.com/tag/days">days {13/1/2014, 22/1/2014}. I want to check if mydate or today in the following code falls on any one of those https://forum.tuteehub.com/tag/days">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 holihttps://forum.tuteehub.com/tag/days">days listed in the arrary are either a M or W).

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

  \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
  \section*{\displaydate{mydate} \quad #1}% Set heading
  \setbox1=\hbox{\shortdayofweekname{\getdateday{mydate}}{\getdatemonth{mydate}}{\getdateyear{mydate}}}%
  \ifdim\wd1=\wd\MONDAY
  \AdvanceDate[2]
  \else
  \AdvanceDate[5]
  \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.

0 views
0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum