将(n)天添加到变量 date 中

将(n)天添加到变量 date 中

我正在尝试将可变日期添加到可变数字。

我目前正在尝试使用datetime2包。我试图得到类似这样的东西(实际上不起作用):

\documentclass[10pt]{article}  
\usepackage[calc, datesep=/]{datetime2}  

\DTMsavedate{ShootDate}{2016-05-20}  
\newcommand{\PaymentTurnAroundDays}{45}  

\begin{document}  
Payment will be made by \DTMusedate{ShootDate}{\PaymentTurnAroundDays}\ (within{\PaymentTurnAroundDays} of the day of the event(s)).  
\end{document} 

呈现为:

付款将于 2016/07/04 (活动当天后 45 分钟内) 之前完成。

这应该将“拍摄日期(2016/05/20)”添加到“付款周转天数(45)”。

答案1

\documentclass[10p]{article}
\usepackage[calc,datesep=/]{datetime2}

\DTMsavedate{ShootDate}{2016-05-20}
\newcommand{\PaymentTurnAroundDays}{45}

\newcount\daycount
\newcommand{\dueDate}[1]{%
    \DTMsaveddateoffsettojulianday{ShootDate}{#1}\daycount
    \DTMsavejulianday{newDate}{\number\daycount}
    \DTMusedate{newDate}
 }

\begin{document}
Payment will be made by \dueDate{\PaymentTurnAroundDays} (within {\PaymentTurnAroundDays} of the day of the event(s)).     
\end{document}

答案2

这是我的建议(虽然不太灵活,但很有效)使用该包datenumber代替datetime2

\documentclass[10pt]{article}  
\usepackage{datenumber}  

\newcommand{\PaymentTurnAroundDays}{45}  
\newcommand{\pnext}{%
\thedateyear/%
\ifnum\value{datemonth}<10 0\fi
\thedatemonth/%
\ifnum\value{dateday}<10 0\fi
\thedateday%
\nextdate
}

\begin{document}  

\setdate{2016}{05}{20} %ShootDate
\addtocounter{datenumber}{\PaymentTurnAroundDays}%
\setdatebynumber{\thedatenumber}%
Payment will be made by \pnext{} (within \PaymentTurnAroundDays{} of the day of the event(s)).

\end{document}

相关内容