# How does showdow work in datetime2?

Since datetime is no longer getting bug fixes, I've been looking at the possibility of switching to datetime2. However, aside from the fact that I'd need to write my own language module, I can't even get to grips with the existing module for English.

Suppose that I want mostly to produce textual dates with the default settings for my locale and I'm using British English at the document level. At some point in the document, though, I'd like to switch the style in which dates are displayed so that the day of the week is also printed.

I'm trying:

\documentclass[british]{article}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[calc]{datetime2}
\DTMsetup{useregional}

\begin{document}
\DTMlangsetup[british]{showdow}\today
\end{document}


I've also tried passing useregional and showdow as options to datetime2 when loading the package but then I get a compilation error. I've tried en-GB, too, because datetime2 doesn't always recognise the british alias. But I didn't get far with that either. And I've tried using the \DTMlangsetup in the preamble with no better luck.

The error I'm getting is

Package datetime2 Warning: Region british' has ignored
(datetime2)                the following settings:
(datetime2)                showdow
on input line 22.


Since I've got a fix for Welsh support in datetime, this is no longer of the immediate interest it was since I'd have to write a language module to switch to datetime2 (rather than just correcting a .def file). But I'd still like to know how datetime2 thinks even though I've no intention of switching unless I really have to. (I'm hoping something I understand better may turn up before then!)

I admit that I find the package extremely confusing: I have no idea at all how the different commands and different files are supposed to play nicely together. (This is not a criticism of the author: datetime2 is just much more ambitious than datetime and I simply don't understand the key concepts underlying its organisational structure.) But I thought from the documentation that showdow ought to work with British English and I don't understand why it doesn't.

• Here's the unsatisfying answer: you can keep everything the same, except for your call to datetime2, which "should" instead read \usepackage[useregional,showdow,calc]{datetime2}. – jon Aug 12 '15 at 2:04
• @jon So it is not possible to toggle showdow within a document? Either it is on or it is off, and that's it? If so, datetime2 is much less flexible on this than datetime, and the documentation should make this limitation much clearer, along with explicit guidance on how to enable it. – cfr Aug 12 '15 at 17:02
• Well, I wonder too. That's why I wrote '"should"' and why I kept it in a comment. I figured the package author would be along soon enough to give a canonical answer that didn't require scare quotes. – jon Aug 13 '15 at 3:33

I've added some more information to the manual for datetime2 v1.2, which I've just uploaded, regarding the showdow setting, but I'll try to clarify.

The showdow setting really ought to be a language-dependent (or contrib package) setting as it's not used by the main datetime2 code and isn't used by a lot of styles, so I did intend to implement it in the same way as the language settings, such as abbr, but the showdow option requires the datetime2-calc package, which calculates the day of week number. Without this extra package, the day of week number can't be calculated, which limits the use of showdow to those commands where the user has explicitly entered the day of week number, for example \DTMdisplaydate{2015}{11}{10}{1}.

I thought it might not be intuitively obvious to most users that they would have to either explicitly load datetime2-calc or use \usepackage[calc]{datetime2} if they wanted to use the showdow setting, so I decided to make showdow a package option, which automatically loads datetime2-calc. I'm sorry if this has confused people.

Since showdow is a package-wide option rather than a language option it can be set using \DTMsetup, but an attempt to switch it on in the document environment without the datetime2-calc package loaded will cause an error. Since this is controlled by the base datetime2 package, this means that the mechanism doesn't have to rely on each language module performing this check.

If you want to define a style that adds a check for the showdow setting, you can use:

 \ifDTMshowdow
\ifnum##4>-1 % space needed after -1
% code that inserts the day of week name
% where the day of week index is given by ##4
\fi
\fi


at the appropriate place where you want to add the weekday name.

(This should be in the redefinition of \DTMdisplaydate and \DTMDisplaydate. Where this occurs inside \DTMnewdatestyle or \DTMnewstyle this requires ##4 instead of #4 to reference the day of week index argument.)

The check for -1 is needed in addition to the check for showdow to allow the user to explicitly ignore the day of week name regardless of the showdow setting. This is primarily for cases where the date must be fully expandable (for example, in PDF bookmarks) which can't be done with the non-expandable commands, such as \DTMdate, that have to calculate the day of week index.

For example:

\documentclass{article}

\usepackage[showdow,en-GB]{datetime2}

`