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)!

  • 1
    Welcome to TeX.SE. This https://tex.stackexchange.com/questions/318006/add-n-days-to-variable-date might be related to your question. – citsahcots Jul 26 '21 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 '21 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 '21 at 13:16

1 Answers1

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.