6

According to the package manual, datetime supports language-sensitive date formats provided that babel is loaded first. The example on page 2 is:

\usepackage[francais]{babel}
\usepackage{datetime}

However, the following code produces incorrect results:

\documentclass{article}
\usepackage[welsh]{babel}
\usepackage{datetime}

\begin{document}

  \today

\end{document}

Not entirely Welsh date

Removing datetime produces a result which, while not actually correct, is at least less incorrect:

Incomplete Welsh date

I assume this is a bug. But is it a bug in datetime or babel's support for Welsh or both? (Or something else but those seem the most likely possibilities.)

Clarification: the issue here is why I get different output in the two cases. The fact that babel's translation is not perfect is a straightforward matter of incomplete localisation. What I'm asking about is why a viz is added when datetime is loaded. This is certainly not Welsh since the alphabet contains neither 'v' nor 'z' and, although 'a' is a Welsh word, it does not belong here.

My current hypothesis is that the bug is a joint effort. First, babel apparently omits to define Welsh ordinals. Second, datetime does not handle cases of impoverished language support appropriately. (Or there is just no way that datetime could do this. But I hope that is not so.)

9
  • 1
    By the way since we don't all speak Welsh, what is the correct/expected output? From looking at the code of datetime, the Welsh output is coded that way... – Werner Sep 25 '14 at 4:00
  • @Werner I'd expect the same output I get without the datetime package i.e. 25 Medi 2014. This could be improved but that's an issue of the translations/localisations provided by babel rather than any kind of interaction between the packages. It is the weird addition of a viz in the output which is really problematic. (Neither 'v' nor 'z' are in the Welsh alphabet and, while 'a' is a Welsh word, it does not belong here.) I've edited the question to try to make this a little clearer. – cfr Sep 25 '14 at 13:08
  • 1
    Since I don't speak Welsh, I implemented datetime to reproduce the same output as babel. (Similarly for all other supported languages.) Since this was done many years ago, it's possible babel has changed the output or I had some kind of brain failure while reading babel's code. datetime was originally intended as a replacement for ukdate before babel existed and I regret not implementing a modular approach where each language module is maintained by someone fluent in that language. I'll fix dt-welsh.def to match babel. – Nicola Talbot Sep 25 '14 at 14:23
  • 1
    I've just had a look at welsh.dtx and it has \changes{welsh-1.0d}{2005/03/31}{removed `a viz' from the definition of \cs{today}} so babel used to produce the same output as datetime. – Nicola Talbot Sep 25 '14 at 14:27
  • Clearly, the date for welsh was originally copypasted from breton. – Javier Bezos Aug 10 '15 at 14:36
5

The file dt-welsh.def seems to be at fault, for it does

\DeclareRobustCommand*\datewelsh{%
\renewcommand{\formatdate}[3]{%
\@day=##1\relax\@month=##2\relax\@year=##3\relax
\ifnum\@day=1\relax 1\/$^{\mathrm{a\tilde{n}}}$\else
\number\@day\fi \space a\space viz\space
\monthnamewelsh[\@month]\space\number\@year}}%

If I redefine \datewelsh in the document like in the following example

\documentclass{article}
\usepackage[welsh]{babel}
\usepackage{datetime}

\makeatletter
\DeclareRobustCommand*\datewelsh{%
\renewcommand{\formatdate}[3]{%
\@day=##1\relax\@month=##2\relax\@year=##3\relax
\ifnum\@day=1\relax 1\/$^{\mathrm{a\tilde{n}}}$\else
\number\@day\fi \space %a\space viz\space
\monthnamewelsh[\@month]\space\number\@year}}%
\makeatother

\begin{document}
\day=0
\loop\ifnum\day<10
  \advance\day by 1
  \today\endgraf
\repeat

\end{document}

I get

enter image description here

Not knowing how Welsh dates should appear this is the best I can do.

The “a viz” part seems to come from Breton (see dt-breton.def).

2
  • Thanks very much. Is it possible to get rid of the superscript stuff following the 1? (It would be OK if it was the right superscript stuff but it isn't. Welsh does not ever use the tilde accent that I know of and 'an' isn't right either.) Can I just remove the \ifnum stuff completely? I'd be tempted to try to do it properly but it would be somewhat more complicated since the superscripts would need to change for other numbers, too. – cfr Sep 25 '14 at 18:31
  • 1
    @cfr Just remove from \ifnum to \fi, leaving just \number\@day. – egreg Sep 25 '14 at 19:27
3

EDIT: To fix the earlier problem with spurious spacing, change the name of the file in \ProvidesFile to dt-welsh.def as well as renaming the file itself (egreg's answer to my question about this):

This is fixed version of dt-welsh.def based on egreg's answer, egreg's comment and the updated gloss-welsh.ldf from the new version of polyglossia.

The licence does not permit me to post a modified version of dt-welsh.def and I cannot figure out a clean way to load a differently named file. This is therefore named dt-cymraeg.def but will work only if renamed to dt-welsh.def. It cannot be distributed in that form, but it can be used in that form on your own system.

Hopefully datetime will eventually be fixed to do something a bit closer to producing correct output without the need for this. Certainly, the package has been updated to not include the a viz, which is something. The current bugs are copied from babel and the author is, I believe, aware of them. Perhaps this will help by providing correct patterns for Welsh.

%% dt-cymraeg.def
%% Additions and changes are copyright 2015 Clea F. Rees
%% Code from dt-welsh.def copyright 2015 Nicola Talbot (see below)
%% Code from gloss-welsh.ldf copyright 2008-2010 François Charette,
%% 2013 Élie Roux, 2011-2015 Arthur Reutenauer
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clea F. Rees.
%
% This work consists of the file dt-cymraeg.def
%
% The file dt-cymraeg.def is a derived work under the terms of the
% LPPL. It is based on dt-welsh.def which is part of the datetime
% package by Nicola Talbot. A copy of datetime, including the
% unmodified version of dt-welsh.def is available from
% http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=datetime.
%
% The modifications are also derivative under the terms of the LPPL. They
% are based on code modified from gloss-welsh.ldf which is part of
% polyglossia 2015/08/06 v1.42.0 by François Charette, Élie Roux
% and Arthur Reutenauer. A copy of polyglossia, including gloss-welsh.ldf
% is available
% from http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=polyglossia.
%%
\ProvidesFile{dt-cymraeg.def}[$Id: dt-cymraeg.def 3789 2015-08-31 02:01:23Z cfrees $]
\providecommand*\dt@cymraeg@neges{%
  \PackageWarning{dt-cymraeg.def}{This is a MODIFIED version of dt-welsh.def. Breakage should under no circumstances be blamed on the author of the original file.}}
\dt@cymraeg@neges
\renewcommand*\dt@cymraeg@neges{\relax}
\providecommand*\ordinaldatewelsh[1]{%
  #1\ifcase#1\relax%
  \or\textsuperscript{af}%
  \or\textsuperscript{ail}%
  \or\textsuperscript{ydd}%
  \or\textsuperscript{ydd}%
  \or\textsuperscript{ed}%
  \or\textsuperscript{ed}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{fed}%
  \else\textsuperscript{ain}\fi}%
\global\let\ordinaldatewelsh\ordinaldatewelsh
\providecommand\dayofweeknameidwelsh[1]{%
dydd\space%
\ifcase#1\relax
\or Sul%
\or Llun%
\or Mawrth%
\or Mercher%
\or Iau%
\or Gwener%
\or Sadwrn%
\fi}%
\global\let\dayofweeknameidwelsh\dayofweeknameidwelsh
\providecommand{\shortdayofweeknameidwelsh}[1]{%
\ifcase#1\relax%
\or Sul%
\or Llun%
\or Maw.%
\or Mer.%
\or Iau%
\or Gwen.%
\or Sad.%
\fi}%
\global\let\shortdayofweeknameidwelsh\shortdayofweeknameidwelsh
\providecommand{\monthnamewelsh}[1][\month]{%
\@orgargctr=#1\relax%
\ifcase\@orgargctr%
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 to 12}%
\or Ionawr%
\or Chwefror%
\or Mawrth%
\or Ebrill%
\or Mai%
\or Mehefin%
\or Gorffennaf%
\or Awst%
\or Medi%
\or Hydref%
\or Tachwedd%
\or Rhagfyr%
\else%
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 to 12}%
\fi}%
\global\let\monthnamewelsh\monthnamewelsh
\DeclareRobustCommand*\datewelsh{%
\renewcommand{\formatdate}[3]{%
  \@day=##1\relax\@month=##2\relax\@year=##3\relax
  \number\@day%
  \ifcase\@day\relax%
  \or\textsuperscript{af}%
  \or\textsuperscript{ail}%
  \or\textsuperscript{ydd}%
  \or\textsuperscript{ydd}%
  \or\textsuperscript{ed}%
  \or\textsuperscript{ed}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{fed}%
  \or\textsuperscript{eg}%
  \or\textsuperscript{fed}%
  \else\textsuperscript{ain}%
  \fi%
  \space%
  \monthnamewelsh[\@month]\space\number\@year}%
}%
\global\let\datewelsh\datewelsh
\providecommand{\shortmonthnamewelsh}[1][\month]{%
\@orgargctr=#1\relax%
\ifcase\@orgargctr%
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 (jan.) to 12 (dec.)}% rhai o Yale ond 'dw i ddim yn cytuno â'i rhai Saesneg chwaith! (efaillai bod nhw'n safonol a ffurfiol?)
\or Ion.%
\or Chwe.% Chwef. yn ôl Yale??!!
\or Maw.%
\or Ebr.%
\or Mai%
\or Meh.%
\or Gorff.%
\or Awst.%
\or Medi%
\or Hyd.%
\or Tach.%
\or Rhag.%
\else%
\PackageError{datetime}{Invalid Month number \the\@orgargctr}{%
Month numbers should go from 1 (jan.) to 12 (dec.)}%
\fi}
\endinput
%%
%% End of file dt-cymraeg.def.

If you want to use this version, copy the contents to a file on your system. Save the file as dt-welsh.def and place it in your personal TEXMF tree or in your working directory. Make a note not to redistribute without renaming the file. Then things should work OK. Make another note to remember that you are using a modified version which will not, therefore, benefit from any updates or bug fixes to the package.

In particular, do NOT report bugs to datetime's author without checking that you can produce them WITHOUT this file in your TEXMF tree.

As far as I can tell, this gets standard date formats right, as well as the long and short forms:

fixed dates for Welsh

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.