0

When I try to use the package datetime2 in conjunction with babel (English), I receive the following warning in the log:

Package datetime2 Warning: Date-Time Language Module `english' not installed on input line 1913.

This is strange for several reasons:

  1. I want to use datetime2's default setting, ISO-style formatting (yyyy-mm-dd) to output my dates. It shouldn't require additional packages for this.
  2. Babel seems to rewrite the default ISO-style formatting to a localized English setting, which is not what I want.
  3. Despite doing something I do not want, it does it correctly. So why is datetime2 still complaining about a missing module?
  4. The line specified by datetime2 does not exist. My mwe is less than 20 lines long and it still specifies line 1913.
  5. ETA: The module warning disappears if I load datetime2 prior to babel. However, datetime2 documentation recommends loading datetime2 after babel to prevent babel overwriting its default settings. Which it still does regardless.

Please help?

I've provided an mwe (I'm using xelatex):

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{datetime2}
% ---------------------------------------------------------------------------- %
\begin{document}
\tableofcontents

\section{Setting the Date}
\subsection{This contains a date}
Here I'm setting a date. 

\today

\end{document}

Here's what I get:

What I get

But here's what I want (which I can only get by not loading babel): What I want

13
  • 1
    Did you read the example with babel at the bottom of page 6 in the datetime2 manual? It loads the babel language as a class option such that both babel and datetime2 gets that option. Then \today gives me y-m-d
    – daleif
    Nov 21, 2023 at 8:59
  • Did you mean the example with "\documentclass[british]{article}"? This does not work properly for me. If I specify "english" (which datetime2 itself indicates is a valid option), nothing happens at all. The date is shown wrong, the module warning persists. Only if I specify "en-US" (or en-GB) does it at least show the date in ISO format, as I want (why???). The warning persists, however. I don't understand why this is the case, and would like to accomplish both. Also, would specifying "english" in the documentclass negatively affect documents with multiple languages?
    – serval
    Nov 21, 2023 at 9:15
  • 1
    This \documentclass[a4paper,english]{article}\usepackage{babel}\usepackage{datetime2}\begin{document}\today\end{document} works as expected for me. Please specify which latex installation you are using and which versions of babel and datetime2.
    – daleif
    Nov 21, 2023 at 9:34
  • Hm, I found out I have to use DTMNow if I want to get a proper output for the ISO date format because according to the datetime2 documentation, LaTeX uses a specific default for it. And apparently I need to install the additional datetime2 module for English in order to get it to work correctly? Weird. Anyway. Thank you for your help, I think you set me on the right path :-)
    – serval
    Nov 21, 2023 at 9:40
  • Again it works just fine for me. But you givve no details about what exactly you have installed at your end and which versions.
    – daleif
    Nov 21, 2023 at 10:05

1 Answer 1

0

In essence, the issue is the specification of the language, "English". There are many variants of English, therefore according to the DateTime2 manual, it will do the default format (see pages 7 and 8). If you wish to use English, rather than, say "British" or some other dialect, then you will need to provide some other specifics, otherwise you will get a warning. Noting that your set the DateTime2 /usepackage instruction after Babel, DateTime2 takes on "English" as the language from Babel, which you have set to "English".

So, to do what you want, namely to get the date in "ISO-style formatting" as you call it, (yyyy-mm-dd), you would replace your instruction \usepackage{datetime2} in your minimal working example (mwe) with \usepackage[style=iso,showisoZ=false]{datetime2}.

To break the options down, style=iso gives you the ISO format and showisoZ=false stops the 'Z' (if you put in other options) and puts the time zone into UTC format - see page 6 of the manual (but it is not actually required in my suggested edit - you could leave that bit out).

Page 22 of the manual shows alternatives, namely to add in the line \DTMsetdatestyle{iso} before \today in your mwe.

I am unsure about your point in 4, but I suspect it is actually reporting the issue back further in its code (sort of like a "stack trace" in programming), since that appears to be a common response for software in an error state.

With regard to your point 5, that is correct - you should load DateTime2 after Babel. However, as demonstrated on page 9 of the manual, you can do it before (but in that example, the manual uses Polyglossia, not Babel).

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Dec 31, 2023 at 8:34

You must log in to answer this question.

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