TeX - LaTeX Asked by Wulle on April 30, 2021
I would like to add years to a given date (without having to care about leapyears).
I should be able to define the date via pgfkeys and after that add years to this date.
For example 01.01.2020 -> +2 -> 01.01.2022
and so on.
The following approach fails in several points in the code (probably due to expansion problems in the DTM-commands)
documentclass{scrartcl}
usepackage{pgf}
usepackage{datetime2}
pgfkeys{mydate/.initial}
newcommand{addyear}[2]{
DTMsavedate{mydate}{#1}
pgfmathparse{int(DTMfetchyear{mydate}+#2)}
pgfmathresult-DTMfetchmonth{mydate}-DTMfetchday{mydate}
}
begin{document}
%%% define date via pgf keys
pgfkeys{/mydate={2020-01-01}}
%%% print date without changing
Date (raw): pgfkeysvalueof{/mydate},
% Formatted: DTMdate{pgfkeysvalueof{/mydate}} % <- not working
%%% add one year
Date (raw): addyear{2020-02-02}{2}
% Date (raw): addyear{pgfkeysvalueof{/mydate}}{2} % <- not working
% Formatted: DTMdate{addyear{pgfkeysvalueof{/mydate}}{2}} % <- not working
end{document}
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP