Latest news 2024-07-03: Ebook sale (1st – 31st July 2024): short story cybercrime fiction Unsocial Media free; short story cybercrime fiction Smile for the Camera free; short story noir crime fiction I’ve Heard the Mermaid Sing free; crime fiction novel The Private Enemy US$1.99; illustrated children’s story The Foolish Hedgehog US$0.99.

datetime2 package FAQ

How do I add a test for the showdow setting to a style? 🔗

You can use the \ifDTMshowdow conditional to determine the showdow setting, but remember that the style should also check if the day of week index has been set to -1 (which indicates that the day of week name should be ignored for a specific use case). So when you redefine \DTMdisplaydate within \DTMnewstyle or \DTMnewdatestyle the test for the day of week name should look something like:

 \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
If you are writing a language module, you need to define \DTMlangweekdayname where lang is the root language label. For example, datetime2-english defines \DTMenglishweekdayname. This naming scheme is needed in order to work with \DTMweekdayname provided by datetime2-calc.sty. (Similarly define \DTMlangWeekdayname for first letter upper case version, \DTMlangshortweekdayname and \DTMlangshortWeekdayname for abbreviated versions, if required.)

If the week or month names include non-ASCII characters, there should be an ASCII version of \DTMlangweekdayname in the file datetime2-lang-ascii.ldf and a UTF-8 version in the file datetime2-lang-utf8.ldf. You might find it easiest to adapt the code from an existing language module. For example, datetime2-french.dtx. This will allow support for multiple file encodings.

You might also want to consider providing a command to use as the separator between the day of week name and the rest of the date. For example, datetime2-en-GB.ldf defines:

\newcommand*{\DTMenGBdowdaysep}{\space}
and also provides a key to change this value with \DTMlangsetup[en-GB]{dowdaysep={separator code}}:
\DTMdefkey{en-GB}{dowdaysep}{\renewcommand*{\DTMenGBdowdaysep}{#1}}
Another example is with datetime2-romanian which is regionless, so datetime2-romanian.ldf provides:
\newcommand*{\DTMromaniandowdaysep}{\space}
and
\DTMdefkey{romanian}{dowdaysep}{\renewcommand*{\DTMromaniandowdaysep}{#1}}

2023-04-14 10:34:05


Permalink: https://www.dickimaw-books.com/faq.php?id=208
Alternative link: https://www.dickimaw-books.com/faq.php?itemlabel=showdowtest

Category: datetime2 package
Topic: Date/Time Styles