2

With the \DTMdisplaydate{yyyy}{mm}{dd}{w} provided in datetime2, one can easily display a specific date. However, one cannot use it directly to display only the year and month, since the third argument cannot left empty. How should one display a time like 2022-01? (Here the option useregional is enabled, so the date should be displayed as a text string in the selected language)

Below is a MWE:

\documentclass{article}

\usepackage[ngerman,french,english]{babel} \usepackage[useregional]{datetime2}

\begin{document}

\selectlanguage{french}

\DTMdate{2022-01-01}

\DTMdisplaydate{2022}{01}{01}{-1}

% \DTMdisplaydate{2022}{01}{}{-1}

\end{document}

Jinwen
  • 8,518
  • According to the documentation, it seems that the predefined format does not support your requirement. You need to set the style yourself. 10.7 Defining a New Date Format in the document may help. – Teddy van Jerry Feb 05 '22 at 03:44

1 Answers1

1

There is a boolean variable showdayofmonth that can be set to false for each language used.

\DTMdefboolkey{french}{showdayofmonth}[false]{} % <<<<<<<<<<<<<<<<
\DTMdefboolkey{german}{showdayofmonth}[false]{} % <<<<<<<<<<<<<<<<  
\DTMdefboolkey{en-GB}{showdayofmonth}[false]{}  % <<<<<<<<<<<<<<<<

a

\documentclass{article}

\usepackage[german,french,british]{babel} \usepackage[useregional]{datetime2}

\parindent0pt \begin{document} \section{Default display}

\selectlanguage{british}

\DTMdate{2022-02-03}

\bigskip

\selectlanguage{french}

\DTMdate{2022-02-03}

\bigskip    

\selectlanguage{german}

\DTMdate{2022-02-03}

\bigskip 

\section{Suppress the display of the day}

\DTMdefboolkey{french}{showdayofmonth}[false]{} % &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
\DTMdefboolkey{german}{showdayofmonth}[false]{} % &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;  
\DTMdefboolkey{en-GB}{showdayofmonth}[false]{}  % &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;

\selectlanguage{british}

\DTMdate{2022-02-03}    

\bigskip

\selectlanguage{french}

\DTMdate{2022-02-03}

\bigskip    

\selectlanguage{german}

\DTMdate{2022-02-03}

\end{document}

Simon Dispa
  • 39,141