Comparação menor que string como \ifstrequal

Comparação menor que string como \ifstrequal

Existe uma maneira de obter um \ifstrlessthancomando que funcione de forma semelhante aetooboxé \ifstrequal? Eu quero fazer algo como

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

Responder1

\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}

estampasnovo nome da empresa

Responder2

Se você remover os hífens, obterá números que podem ser comparados:

\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}

insira a descrição da imagem aqui

informação relacionada