[Tex/LaTex] How to print a given date with an abbreviated month

datetimeformatting

The best I've been able to do is with isodate. It's the only package I've been able to find that works on arbitrary dates.

\usepackage[orig, british, cleanlook]{isodate}
\printdate{2013-06-28}

produces:

28 June 2013

I'm looking to have the month abbreviated to match our existing documentation format. I would like to end up with:

28 Jun 2013

Where all the months are abreviated. I'm thinking maybe I need to make a custom language for isodate, but there must be a better way.

Update:

I have also looked at the datetime package's \formatdate command. Unfortunately the date comes in as a solid string and I don't have the option of splitting it to the separate fields that the command needs.

I would be satisfied with something along the lines of:

\formatdate{\getday{2013-06-28}}{\getmonth{2013-06-28}}{\getyear{2013-06-28}}

That could be defined to a new command that would be easier to use.

Best Answer

You can update the English month lookup to suit your needs:

enter image description here

\documentclass{article}
\usepackage[orig, british, cleanlook]{isodate}% http://ctan.org/pkg/isodate
\begin{document}

\printdate{2013-06-28}% Old date format

\makeatletter
% Update English month lookup
\def\month@english{\ifcase\month\or
    Jan\or Feb\or Mar\or Apr\or May\or Jun\or
    Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi}
\makeatother

\printdate{2013-06-28}% New date format

\end{document}

The above suggests a global change to the English month lookup. If you want a more localized version, you could include the following in your document preamble:

\makeatletter
\def\short@month@english{\ifcase\month\or
    Jan\or Feb\or Mar\or Apr\or May\or Jun\or
    Jul\or Aug\or Sep\or Oct\or Nov\or Dec\fi}
\newcommand{\printshortdate}[1]{{%
  \let\month@english\short@month@english% Update English month lookup (locally)
  \printdate{#1}}}% Call traditional \printdate
\makeatother

which allows you to use \printdate and/or \printshortdate interchangably. \printshortdate updates \month@english temporarily (note the nested braces {..}) before calling the traditional \printdate macro.