3

With the following MWE, I get two warnings:

\documentclass{article}

\usepackage[en-US]{datetime2}

\begin{document}

\DTMlangsetup{showyear=false}
\DTMdate{2017-03-13}
\DTMlangsetup{showyear=true}

\end{document}

Those warnings are:

Package datetime2 Warning: Region `english-base' has ignored 
(datetime2)                the following settings:
(datetime2)                showyear=false
 on input line 7.

Package datetime2 Warning: Region `english-base' has ignored 
(datetime2)                the following settings:
(datetime2)                showyear=true
 on input line 9.

Despite those warnings stating the setting was ignored, the result is March 13 as expected. Will this cause problems in the future if I do not plan on using babel and the datetime2-* language packages, or is it simply a result of using the default language package and so datetime2 is getting confused?

(While removing [en-US] results in the warnings going away, it also results in the date being printed as 2017-03-13, which is not desirable.)

2
  • Possible duplicat with this answer tex.stackexchange.com/a/277621/124842 – Bobyandbob Mar 13 '17 at 15:28
  • @Bobyandbob In that question, the user appears to not be able to use the option. In my case, the option works despite the warning. – JAB Mar 13 '17 at 15:44
5

If the optional argument to \DTMlangsetup is not used, it will iterate over all loaded datetime2 language files and apply the settings to each in turn. In the case of en-US, this list is en-US and english-base. The english-base language module is loaded by all the en-region modules, as that's the file that defines the month and day of week names. So \DTMlangsetup{showyear=false} attempts \DTMlangsetup[en-US]{showyear=false}, which works but it also attempts \DTMlangsetup[english-base]{showyear=false}, but this module doesn't have this setting, which is why there's a warning.

There are two approaches if you want to avoid the warning:

  1. Use the optional argument to indicate the exact language module: \DTMlangsetup[en-US]{showyear=false}

  2. Use the starred form, which doesn't issue a warning: \DTMlangsetup*{showyear=false}. (Requires datetime2 v1.3+)

1
  • 1
    Looking up the starred version in the datetime2 documentation, I see that it explains exactly this. The starred form seems more dangerous as it suppresses warnings even for settings that aren't in any of the modules, so I'll go with the first choice. – JAB Mar 13 '17 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.