11

The \today command will print the Latin name of the month with the nynorsk language option. I would like to change this by using the more traditional (and still very commonly used in speech) system of using the ordinal number "first", "second", etc. (abbreviated from "first month", "second month", etc.).

All it requires is to substitute the month names by i X, where i is the preposition "in" and X the ordinal, as seen in the table below. What's the most convenient way of doing that? With the datetime2 package?

\documentclass{article}
\usepackage[nynorsk]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
\today\\

\begin{tabular}{*5{l}}
januar & i fyrste & & juli & i sjuande\\
februar & i andre & & august & i åttande\\
mars & i tredje & & september & i niande\\
april & i fjerde & & oktober & i tiande\\
mai & i femte & & november & i ellevte\\
juni & i sjette & & desember & i tolvte\\
\end{tabular}
\end{document}

enter image description here

For those who wonder - ordinals in Norwegian are definite, so there's no need for a definite article or determiner of any kind, as in English "in the first (month)", "in the second (month)", etc.

13
\documentclass{article}
\usepackage[nynorsk]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\renewcommand\datenynorsk{%
 \def\today{\number\day.~\ifcase\month\or
    i fyrste\or i andre\or i tredje\or i fjerde\or i femte\or i sjette\or
    i sjuande\or i åttande\or i niande\or i tiande\or i ellevte\or
    i tolvte\fi
    \space\number\year}}

\begin{document}
\today


\end{document}

enter image description here

  • I'm going to delete my answer in favour of this, even though I saved 22 whole bytes by pulling the i out to the front:-) – David Carlisle Oct 26 '15 at 16:36
  • @DavidCarlisle: A member of the latex3 team should write verbose code and not try to save 22 bytes ;-) – Ulrike Fischer Oct 26 '15 at 16:58
3

Since you asked for datetime2, you just need to redefine the month name macros:

\documentclass{article}
\usepackage[nynorsk]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[useregional]{datetime2}

\renewcommand*{\DTMnorskmonthname}[1]{%
  \ifcase#1
  \or
  i fyrste%
  \or
  i andre%
  \or
  i tredje%
  \or
  i fjerde%
  \or
  i femte%
  \or
  i sjette%
  \or
  i sjuande%
  \or
  i åttande%
  \or
  i niande%
  \or
  i tiande%
  \or
  i ellevte%
  \or
  i tolvte%
  \fi
}

\renewcommand*{\DTMnorskMonthname}[1]{%
  \ifcase#1
  \or
  I fyrste%
  \or
  I andre%
  \or
  I tredje%
  \or
  I fjerde%
  \or
  I femte%
  \or
  I sjette%
  \or
  I sjuande%
  \or
  I åttande%
  \or
  I niande%
  \or
  I tiande%
  \or
  I ellevte%
  \or
  I tolvte%
  \fi
}

\begin{document}
\today

Specific date: \DTMdate{2015-10-26}.
\end{document}

10. i ellevte 2015. Specific date: 26. i tiande 2015.

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.