I have made a command that looks like this:
\newcommand*{\numdash}{\,--\,}
\ExplSyntaxOn
\NewDocumentCommand{\dateRange}{mmmmmm}
{
\str_case:nnF { #1 }
{
{#4} {
\str_case:nnF { #2 }
{
{#5} {
\str_case:nnF { #3 }
{
{#6} { \DTMdisplaydate{#4}{#5}{#6}{-1} }%
}{\DTMordinal{#3}{}{}\numdash{}\DTMdisplaydate{#4}{#5}{#6}{-1}}
}
}{\DTMordinal{#3}~\DTMmonthname{#2}%
{}\numdash{}\DTMdisplaydate{#4}{#5}{#6}{-1}}
}
}{\DTMdisplaydate{#1}{#2}{#3}{-1}{}\numdash{}\DTMdisplaydate{#4}{#5}{#6}{-1}}
}
\ExplSyntaxOff
It displays the duration from one date to the next in a succinct matter. See the image below.
However, I need to manipulate the end date by incrementing it by a few days.
Something like \dateRange{2016}{12}{31}{2016}{12}{31 + 1} does not work.
I found the following code
%https://tex.stackexchange.com/questions/318006/add-n-days-to-variable-date
\DTMsavedate{DeadLineDate}{2016-05-20}
\newcommand{\DeadLineDateExtend}{1}
\newcount\daycount
\newcommand{\dueDate}[1]{%
\DTMsaveddateoffsettojulianday{DeadLineDate}{#1}\daycount
\DTMsavejulianday{newDeadLineDate}{\number\daycount}
\DTMusedate{newDeadLineDate}
}
Which can add days to a DTMdate. My problem is making these two functions work together.
- Rewrite
dateRangeso that it inputs twoDTMdatesinstead of the plain numbers. - Exctract the year, month and date from
newDeadLineDateand insert it back intodateRange
So what I need help with is to first have two dates, increment one of them and display the daterange using \dateRange function. Any help with 1. or 2. from the list above is greatly appreciated.
\documentclass{article}
\usepackage[english]{babel}
\usepackage[en-GB,calc]{datetime2}
\usepackage{xparse}
% https://tex.stackexchange.com/questions/390693/datetime-ranges-using-datetime2/390738
\newcommand*{\numdash}{\,--\,}
\ExplSyntaxOn
\NewDocumentCommand{\dateRange}{mmmmmm}
{
\str_case:nnF { #1 }
{
{#4} {
\str_case:nnF { #2 }
{
{#5} {
\str_case:nnF { #3 }
{
{#6} { \DTMdisplaydate{#4}{#5}{#6}{-1} }%
}{\DTMordinal{#3}{}{}\numdash{}\DTMdisplaydate{#4}{#5}{#6}{-1}}
}
}{\DTMordinal{#3}~\DTMmonthname{#2}%
{}\numdash{}\DTMdisplaydate{#4}{#5}{#6}{-1}}
}
}{\DTMdisplaydate{#1}{#2}{#3}{-1}{}\numdash{}\DTMdisplaydate{#4}{#5}{#6}{-1}}
}
\ExplSyntaxOff
%https://tex.stackexchange.com/questions/318006/add-n-days-to-variable-date
\DTMsavedate{DeadLineDate}{2016-05-20}
\newcommand{\DeadLineDateExtend}{1}
\newcount\daycount
\newcommand{\dueDate}[1]{%
\DTMsaveddateoffsettojulianday{DeadLineDate}{#1}\daycount
\DTMsavejulianday{newDeadLineDate}{\number\daycount}
\DTMusedate{newDeadLineDate}
}
\begin{document}
\dateRange{2016}{12}{31}{2016}{12}{31}
\dateRange{2016}{12}{30}{2016}{12}{31}
\dateRange{2016}{11}{31}{2016}{12}{31}
\dateRange{2015}{12}{31}{2016}{12}{31}
\end{document}

