0

I am just a few hours new to TeX and have been tasked to modify an existing template (tex) document for parsing.

I have this in an cls file that works fine to add #1 days to today's date:

\newcommand*{\duedate}[1]{%
    \setdatetoday%
    \addtocounter{datenumber}{#1}%
    \setdatebynumber{\thedatenumber}%
    \datedate%
}

However, I need to change it to a base date #2 I would pass in as an additional parameter, and then have it add #1.

I tried using \date, but it continues to pickup today's date.

\newcommand*{\duedate}[2]{%
    \date{#2}%
    \addtocounter{datenumber}{#1}%
    \setdatebynumber{\thedatenumber}%
    \datedate%
}

As well as \setdate.

However, the output is always today's date + #1.

If there is documentation to read on how to set a date, and add "days" to a date, please point me to it. I'd be more than happy to read up on proper syntex (phun)!

3
  • 1
    Welcome to TeX.SE. This tex.stackexchange.com/questions/318006/… might be related to your question.
    – citsahcots
    Jul 26, 2021 at 21:27
  • @modnar it took some time to figure out, but I posted the hacked solution as an answer below. it's not ideal though, because there's a conflict between datanumber in my cls, and this datetime2 package. So if there's a way to resolve my question with just the OP code, it would be preferred so I do not have to define the function in the answer below.
    – eduncan911
    Jul 26, 2021 at 23:05
  • Can you please provide minimla code (MWE) which makes \duedate run? Don't want to try all sorts of missing packages ;-) Thanks
    – MS-SPO
    Jul 27, 2021 at 13:16

1 Answer 1

0

After evaluating the link in @modnar's comment, this would work:

\usepackage[calc,en-US]{datetime2}
\newcommand{\dueDate}[2]{%
    \DTMsavedate{InvoiceDate}{#2}
    \newcount\daycount
    \DTMsaveddateoffsettojulianday{InvoiceDate}{#1}\daycount
    \DTMsavejulianday{newDate}{\number\daycount}
    \DTMusedate{newDate}
 }

However, this produces a conflict between datetime2 and datenumber in the cls file.

So the above code must live in the main .tex document at this time.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .