![advdate 和 datetime2 与星期几](https://linux22.com/image/466969/advdate%20%E5%92%8C%20datetime2%20%E4%B8%8E%E6%98%9F%E6%9C%9F%E5%87%A0.png)
我想以以下格式增加日期
[星期几] [日] [月] [年]
每一步增加一个,但我无法让星期几增加。我一直在寻找这个答案但我无法让 dow 正常前进。
\documentclass{article}
\usepackage[british]{babel}
\usepackage[useregional,showdow]{datetime2}
\usepackage{advdate}
\usepackage{etoolbox}
\makeatletter
\appto\FixDate{%
\edef\@dtm@currentyear{\the\year}%
\edef\@dtm@currentmonth{\the\month}%
\edef\@dtm@currentday{\the\day}%
% \edef\@dtm@currentdow{\the\dow}%??
}
\makeatother
\begin{document}
\today
\AdvanceDate[1]
\today
\AdvanceDate[1]
\today
\AdvanceDate[1]
\today
\AdvanceDate[1]
\today
\end{document}
答案1
这是仅使用datetime2
:
\documentclass{article}
\usepackage[british]{babel}
\usepackage[useregional,showdow]{datetime2}
\NewDocumentCommand{\TODAY}{}{%
\DTMifsaveddate{now}{}{\DTMsavenow{now}}% If "now" date doesn't exist, set it
\DTMusedate{now}% Print date
}
% Partly taken from https://tex.stackexchange.com/a/318012/5764
\newcount\daycount
\NewDocumentCommand{\AdvanceTODAY}{ O{1} }{%
\DTMsaveddateoffsettojulianday{now}{#1}\daycount% Identify Julian days
\DTMsavejulianday{now}{\number\daycount}% Set new date
}
\begin{document}
\TODAY
\AdvanceTODAY% Defaults to advance 1 day
\TODAY
\AdvanceTODAY[1]
\TODAY
\AdvanceTODAY[2]
\TODAY
\end{document}