3

I can't seem to change datetime2's settings when using the option useregional to display the date in the language given to babel

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage[useregional]{datetime2}
%
\DTMnewdatestyle{mydatestyle}{
  \renewcommand*{\DTMdisplaydate}[4]{##3 \DTMmonthname{##2}}
  \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}
}
\DTMsetdatestyle{mydatestyle}
% -------------------
\begin{document}
\today
\end{document}

I'd like the output to be 08 settembre, with the leading zero in front of the 8 and without the year, but I'm still getting the default 8 settembre 2019.

What am I doing wrong?

1 Answer 1

3

Well, the main issues in your code are the following:

  1. You need to use option calc for datetime2.
  2. Use option useregional=text for datetime2.
  3. Move command \DTMsetdatestyle{mydatestyle} after \begin{document}.
  4. Use command \DTMtwodigits{##3} to get the leading zero ...

Please see the following MWE

\documentclass[italian]{article}

\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage[%
  useregional=text, % <=================================================
  calc % <==============================================================
]{datetime2}

\DTMnewdatestyle{mydatestyle}{%
  \renewcommand*{\DTMdisplaydate}[4]{\DTMtwodigits{##3} \DTMmonthname{##2}} % <============ year month day dow
  \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}
}


\begin{document}

\DTMsetdatestyle{mydatestyle} % <=======================================
\today

\end{document}

and its result:

resulting date

2
  • 2
    wow, this is my third question in a row that you answer in the span of 12 hours! Thanks a lot
    – noibe
    Commented Sep 8, 2019 at 15:57
  • 2
    @noibe :-) You are welcome!
    – Mensch
    Commented Sep 8, 2019 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .