# datenumber: define \dateshortmonthname

I am working with datenumber package with spanish option, \usepackage[spanish]{datenumber} and I want to define a command similar to \datemonthname, but each month with the first 3 letters, I mean

enero=ene, febrero=feb, marzo=mar, mayo=may,

etc.

The first three (or more characters) of a string can be extracted with \StrLeft{somestring}{3} from the xstring package.

I wrapped a macro named \dateshortmonthname with one optional argument around \StrLeft{\datemonthname}{#1} where #1 defaults to 3 if not specified otherwise (or not at all).

\documentclass[spanish]{article}

\usepackage{datenumber}
\usepackage{xstring}

\usepackage{pgffor} % only for demo

\newcommand{\dateshortmonthname}[1][3]{%
\StrLeft{\datemonthname}{#1}%
}

\begin{document}

\foreach \x in {1,...,12} {%
\setdatenumber{2015}{\x}{22}
Current month: \datemonthname~ -- short is \dateshortmonthname

}
\end{document}


Note The datenumber package is quite old and no changes have been made to it since about 15 years.

• “This should be expandable, in my point of view.” I'm not sure what you mean by that, but that's not expandable. – Manuel May 22 '15 at 21:54
• @Manuel: Right, it isn't. I will remove the statement. Thanks for complaining – user31729 May 22 '15 at 22:00