4

I'm trying to create a date style that results in

01 JUN 2020

\documentclass{article}
\usepackage[USenglish]{babel}
\usepackage[showseconds=false,useregional=text,calc]{datetime2}
\DTMnewdatestyle{mydatestyle}
{
    \renewcommand*{\DTMdisplaydate}[4]{
        \DTMtwodigits{##3} \MakeUppercase{\DTMshortmonthname{##2}} ##1}
    \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}
}
\begin{document}

\DTMsetdatestyle{mydatestyle}
\today

\end{document}

but no matter where I wrap \MakeUppercase around it, it gives me

01 Jun 2020

Is there a way to simply change the case of the date without needing to redefine the month names? (which I cannot get to work with my datetime2 example, while the answers there work out of the box.

kjekk
  • 43
  • 3

1 Answers1

3

That's because \DTMshortmonthname (like many others) are defined via datetime2-calc package and are robust. You can either use the language-specific alternative \DTMenglishshortmonthname or define your own \MYshortmonthname that isn't robust and will work with \MyUppercase:

enter image description here

\documentclass{article}

\usepackage[USenglish]{babel}
\usepackage[showseconds=false,useregional=text,calc]{datetime2}

\DTMnewdatestyle{mydatestyle}{%
  \renewcommand*{\DTMdisplaydate}[4]{%
    \DTMtwodigits{##3} \MakeUppercase{\MYshortmonthname{##2}} ##1}% ...or \DTMenglishshortmonthname
  \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}%
}

\newcommand{\MYshortmonthname}[1]{%
  \ifcase#1% 0
    \or Jan%
    \or Feb%
    \or Mar%
    \or Apr%
    \or May%
    \or Jun%
    \or Jul%
    \or Aug%
    \or Sep%
    \or Oct%
    \or Nov%
    \or Dec%
  \fi
}

\begin{document}

\DTMsetdatestyle{mydatestyle}
\today

\end{document}
Werner
  • 603,163