4

I have tried to figure out how to enable printing the day of week, but I cannot seem to be able to do this for norwegian. It works fine for British. I do realize that it might be because it is normally left out of dates in norwegian, but it should work when I force it.

\documentclass[11pt,norwegian]{article}
\usepackage[useregional,showdow,calc]{datetime2}
\begin{document}

\DTMdate{2015-11-09}
\end{document}

Produces: 9. november 2015

\documentclass[11pt,british]{article}
\usepackage[useregional,showdow,calc]{datetime2}
\begin{document}

\DTMdate{2015-11-09}
\end{document}

While this produces: Monday 9th November 2015

I need this to work for any given date, not just for today.

Thanks in advance.

3
  • Not all language modules implement the showdow option. datetime2-norsk doesn't. For those of us who don't speak Norwegian, could you give some information as to how the day of week name should appear in dates, and maybe someone can provide a modified style. Nov 9, 2015 at 19:50
  • I see from the datetime2-norsk documentation that it is not maintained anymore, and that there is a note to implement showdowin a future release. The weekdays are actually added for the \DTMnorskWeekdayname . Maybe somebody with the knowledge could write it in? In the meantime, I have made a hack that makes it work for my document, but it would be nice to have it working with the official one.
    – Runar
    Nov 9, 2015 at 20:03
  • I asked for volunteers to help maintain the language modules, as unfortunately I don't have time to support them all. (There are rather a lot of them.) I've had a few volunteers but no one for the datetime2-norsk module yet. Hopefully someone will step forward and implement it sometime soon. Nov 10, 2015 at 8:53

2 Answers 2

6

Here's a patched version of the norsk date style:

\documentclass[11pt,norwegian]{article}
\usepackage[useregional,showdow,calc]{datetime2}

% undefine the norsk date style so \DTMnewdatestyle doesn't cause an error    
\csundef{@dtm@datestyle@norsk}

\DTMnewdatestyle{norsk}{%
   \renewcommand*\DTMdisplaydate[4]{%
     \ifDTMshowdow
       \ifnum##4>-1
         \DTMnorskweekdayname{##4}%
         \space
       \fi
     \fi
     \DTMifbool{norsk}{showdayofmonth}
     {\DTMnorskordinal{##3}\DTMnorskdaymonthsep}%
     {}%
     \DTMnorskmonthname{##2}%
     \DTMifbool{norsk}{showyear}%
     {%
       \DTMnorskmonthyearsep
       \number##1
     }%
     {}%
   }%
   \renewcommand*\DTMDisplaydate[4]{%
     \ifDTMshowdow
       \ifnum##4>-1
         \DTMnorskWeekdayname{##4}%
         \space
       \fi
     \fi
     \DTMifbool{norsk}{showdayofmonth}
     {%
       \DTMnorskordinal{##3}\DTMnorskdaymonthsep
       \DTMnorskmonthname{##2}%
     }%
     {%
       \ifDTMshowdow
         \ifnum##4>-1
           \DTMnorskmonthname{##2}%
         \else
           \DTMnorskMonthname{##2}%
         \fi
       \else
          \DTMnorskMonthname{##2}%
       \fi
     }%
     \DTMifbool{norsk}{showyear}%
     {%
       \DTMnorskmonthyearsep
       \number##1
     }%
     {}%
   }%
}

\DTMsetdatestyle{norsk}

\begin{document}

\DTMdate{2015-11-09}
\end{document}

This produces:

mandag 9. november 2015

Edit:

I've just uploaded datetime2 v1.2 to CTAN, which now allows you to redefine styles. It will probably take a few days to get into the distributions, but once it's available the \csundef hack won't be necessary and you can replace the lines:

% undefine the norsk date style so \DTMnewdatestyle doesn't cause an error    
\csundef{@dtm@datestyle@norsk}

\DTMnewdatestyle{norsk}{%

with just

\DTMrenewdatestyle{norsk}{%
1
  • 1
    Thank you, this is great. Hopefully somebody will take over the maintanance of your `date time2-norsk-package.
    – Runar
    Nov 10, 2015 at 10:03
3

I made a simple hack to make it work with a new command. This is not a good way to fix it, but it gets the job done until somebody edit the official Norwegian language module.

\documentclass[11pt,norwegian]{article}
\usepackage[useregional,showdow,calc]{datetime2}
\usepackage{xparse}
\NewDocumentCommand{\dato}{sm} % hack to force day of week to be shown.
         {\DTMsavedate{datooo}{#2}\IfBooleanTF{#1}
           {\DTMnorskWeekdayname{\DTMfetchdow{datooo}} \DTMusedate{datooo}
           }
           {\DTMnorskweekdayname{\DTMfetchdow{datooo}} \DTMusedate{datooo}
           }
        }
\begin{document}
\dato{2015-11-09}
\dato*{2015-11-09}
\end{document}

Produces: mandag 9. november 2015 Mandag 9. november 2015

You must log in to answer this question.

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