advdate and skip dates based on holidays

Course Queries Syllabus Queries 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 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.

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.