根據假日提前日期和跳過日期

根據假日提前日期和跳過日期

我正在從這裡的問題中跟進。我的主要目的是為課程編寫教學大綱和時間表,該課程僅在一周中的某些日子進行(考慮到一些假期)。在這個問題,我問過如何跳過非 M 或 W 的工作日。

現在,如果當前上課日恰逢假期,我想跳到下一個上課日。假設我有一個假期清單 {13/1/2014, 22/1/2014}。我想檢查以下程式碼中的 mydate 或 Today 是否屬於這些日子中的任何一天,並根據情況跳到下一個上課日(M 或 W)。例如,我希望第三類落在 15/1,第六類落在 27/1。如果它不能完全概括(即不需要檢查年份,我可以確保數組中列出的假期是 M 或 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}

我正在考慮使用,\foreach但這不起作用,因為foreach會跳過列表的每個元素。我認為可行,但退出循環後\AdvanceDate[0]似乎沒有儲存。\today任何幫助表示讚賞。

相關內容