Kleiner-als-Stringvergleich wie \ifstrequal

Kleiner-als-Stringvergleich wie \ifstrequal

Gibt es eine Möglichkeit, einen \ifstrlessthanBefehl zu erhalten, der ähnlich funktioniert wieAbonnieren's \ifstrequal? Ich möchte etwas tun wie

\ifstrlessthan{\creationdate}{2017-01-01}%
  {Old company name}{New company name}

Antwort1

\documentclass{article}
\usepackage{pdftexcmds}
\newcommand{\companyNameChangeDate}{2016-01-01}
\newcommand{\creationDate}{2017-01-01}
\begin{document}
\makeatletter
\ifcase\pdf@strcmp{\creationDate}{\companyNameChangeDate} new company name \or new company name \else old company name \fi
\makeatother
\end{document}

drucktneuer Firmenname

Antwort2

Entfernt man die Bindestriche, erhält man vergleichbare Zahlen:

\documentclass{article}

% assume dates are in ISO format YYYY-MM-DD
\makeatletter
\newcommand{\ifdateearlierTF}[2]{%
  \ifnum\@date@to@number{#1}<\@date@to@number{#2}
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\def\@date@to@number#1{\expandafter\@date@to@number@aux\romannumeral-`Q#1\@nil}
\def\@date@to@number@aux#1-#2-#3\@nil{#1#2#3}
\makeatother


\begin{document}

\newcommand{\creationdate}{2016-01-01}
\ifdateearlierTF{\creationdate}{2017-01-01}{Old company name}{New company name}

\renewcommand{\creationdate}{2017-06-30}
\ifdateearlierTF{\creationdate}{2017-01-01}{Old company name}{New company name}

\end{document}

Bildbeschreibung hier eingeben

verwandte Informationen