Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

advdate and skip dates based on holidays

Course Queries Syllabus Queries

Max. 2000 characters
Replies

usr_profile.png

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
 \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.

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif