# Bug Tracker

ID: 13 🔗 Closed (Fixed) datetime 2.58 2013-01-07 20:16:28 name-clash (\ifleapyear / \@modulo) with macros of packages datetime and datenumber

## Report

\documentclass{minimal}
\usepackage{datenumber,datetime}
\setstartyear{1991}
\begin{document}
\end{document}

Hello, the minimal exmple above delivers a bunch of errors:
| ! You can't use the character 8' after \advance.
| <inserted text> 8
|                  038
| l.3 \setstartyear{1991}
|
| ?
|
| ! LaTeX Error: Missing \begin{document}.
|
| See the LaTeX manual or LaTeX Companion for explanation.
| Type  H <return>  for immediate help.
|  ...
|
| l.3 \setstartyear{1991}
|
| ?
| Missing character: There is no 0 in font nullfont!
| Missing character: There is no 3 in font nullfont!
| Missing character: There is no 8 in font nullfont!
| Missing character: There is no b in font nullfont!
| Missing character: There is no y in font nullfont!
| Missing character: There is no - in font nullfont!
| ! Missing number, treated as zero.
|                     \global
|  l.3 \setstartyear{1991}
|
|  ?

According to the log-file
Package: datenumber 2001/08/06v0.02

and
Package: datetime 2010/09/21 v2.58 Date Time Package

were in use.

Within the package datenumber everything is defined in terms of \def .

Thus within the example below - right before calling the package datenumber - I locally redefined \def to also \show the meaning of the command in question before defining it:

\documentclass{minimal}
\usepackage{datetime}
\begingroup
\let\olddef=\def
\def\def#1{\show#1\olddef#1}%
\usepackage{datenumber}
\endgroup
\begin{document}
\end{document}


This way I found out that there are name-clashes with names of the packages datenumber and datetime.

E.g., the control-sequences \ifleapyear and \@modulo were alredy defined by datetime and the package datenumber silently overrode them.

In package datenumber \ifleapyear (and \ifvaliddate) seems to be a macro. Macro-names should not begin with \if... in order to avoid confusion with real \if..-condition-switches defined in terms of \newif.

I suggest either of the packages to stick to its own namespace and to use \newcommand instead of \def in order to avoid such things.

Namespace "XY" could, e.g., be implemented like this:

\newcommand\XYname{}%
\long\def\XYname#1#{\romannumeral\XYinnername{#1}}%
\newcommand\XYinnername[2]{%
\expandafter\XYexchange\expandafter{\csname XY#2\endcsname}{0 #1}%
}%
\newcommand\XYexchange[2]{#2#1}%
\newcommand\XY{XY}
[...]
% defining macros within the namespace:
\XYname\newcommand*{mymacro}[2]{definition-text}
\XYname\global\long\def{myothermacro}#1#2{definition-text}
% calling macros from within the namespace:
\XYname{mymacro}{Arg1}{Arg2}
\XYname{myothermacro}{Arg1}{Arg2}
\csname\XY mymacro\endcsname{Arg1}{Arg2}
\csname\XY myothermacro\endcsname{Arg1}{Arg2}
\XYmymacro{Arg1}{Arg2}
\XYmyothermacro{Arg1}{Arg2}
\csname XYmymacro\endcsname{Arg1}{Arg2}
\csname XYmyothermacro\endcsname{Arg1}{Arg2}


Sincerely

Ulrich

### MWE

\documentclass{minimal}
\usepackage{datenumber,datetime}
\setstartyear{1991}
\begin{document}
\end{document}


# Evaluation

datetime v2.59 now defines \ifDTleapyear. To ensure backward-compatibility, if \ifleapyear hasn't been defined, it's defined to be \ifDTleapyear. The \@modulo command is defined in fmtcount rather than datetime. This will be fixed in future versions of fmtcount. To cover the overlap between releases of the datetime and fmtcount, datetime uses \@FCmodulo instead of \@modulo, but there's a check to see if \@FCmodulo has been defined after loading fmtcount. If it hasn't then \@FCmodulo is set to \@modulo`.

There's nothing I can do about datenumber's use of \def. You'll have to raise the issue with datenumber's maintainer. LaTeX3 should hopefully solve the problem of namespaces.

## Watch This Report

If you supply your name, it will be used in the email greeting, which provides a more personal message, otherwise you'll just get a generic greeting. If you have previously supplied your name when signing up for notifications, you don't need to resupply it unless you want to change it.

If you have previously subscribed to notifications for this report, you can unsubscribe by clicking on the "Stop Notification" button.

The "Confirm Bug ID" field helps to protect against spambots. Please enter the bug ID (which you can find at the top of this page).

Name: (Optional.)