我的g-brief
遗嘱中包含类似“我已注意到您答复的截止日期为十个工作日,直到……”的内容。
是否有一个软件包或方法可以通过n
编程将工作日(即周一至周五,不要让假期等使事情变得过于复杂)添加到今天的日期?
我找到了一个近似解在datenum
和advdate
包中:
\setdatetoday
\addtocounter{datenumber}{10}
\setdatebynumber{\thedatenumber}
但这“仅”*添加了天数,而不考虑一天是工作日还是休息日(即周末)。
*在谦卑中“我自己不可能做任何类似的事情(所以我很感激),但它并不完全符合我的需要,可能需要进行调整”-方式。
答案1
以下是使用该pgfcalendar
包的解决方案(pgf
捆。)
\documentclass{article}
\usepackage{pgfkeys,pgfcalendar}
\newcount\julianday
\newcount\daycount
\newcount\weekday
\newcommand*{\adddays}[2]{%
\pgfcalendardatetojulian{#1}{\julianday}%
\daycount=#2\relax
\loop
\advance\julianday by 1\relax
\pgfcalendarjuliantoweekday{\julianday}{\weekday}%
\ifnum\weekday<5\relax
% It's a weekday (Mon-Fri)
\advance\daycount by -1\relax
\fi
\ifnum\daycount > 0
\repeat
\pgfcalendarjuliantodate{\julianday}{\thisyear}{\thismonth}{\thisday}%
\thisyear-\thismonth-\thisday
}
\begin{document}
10 working days from
\the\year-\the\month-\the\day\ (today):
\adddays{\year-\month-\day}{10}
\end{document}
得出的结果为:
您可以调整此设置以将节假日考虑进去:
\documentclass{article}
\usepackage{pgfkeys,pgfcalendar}
\usepackage{etoolbox}
\newcount\julianday
\newcount\daycount
\newcount\weekday
\newcommand*{\holiday}[2]{%
\pgfcalendardatetojulian{#1}{\julianday}%
\csdef{holiday-\number\julianday}{#2}%
}
\newcommand*{\adddays}[2]{%
\pgfcalendardatetojulian{#1}{\julianday}%
\daycount=#2\relax
\loop
\advance\julianday by 1\relax
\pgfcalendarjuliantoweekday{\julianday}{\weekday}%
\ifnum\weekday<5\relax
% It's a weekday (Mon-Fri)
\ifcsdef{holiday-\number\julianday}%
{% It's a holiday
}%
{% Not a holiday
\advance\daycount by -1\relax
}%
\fi
\ifnum\daycount > 0
\repeat
\pgfcalendarjuliantodate{\julianday}{\thisyear}{\thismonth}{\thisday}%
\thisyear-\thismonth-\thisday
}
\holiday{2014-04-21}{Easter Monday}
\holiday{2014-05-05}{Early May Bank Holiday}
\begin{document}
10 working days from
\the\year-\the\month-\the\day\ (today):
\adddays{\year-\month-\day}{10}
\end{document}
得出的结果为: