Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the vc bundle to feed \date with the date from the latest git commit. Is there a way to format this date in the same format as the output from \today? I know of the different date formats in the vc bundle manual but none correspond to the format of today.

Here's an example to work with:

\immediate\write18{./vc}
\input{vc}
\documentclass{article}
\usepackage[utf8]{inputenc}

\title{[Title]}
\date{\VCDateISO}% I want to format this date...

\begin{document}

\maketitle

\today% ... like this date.

\end{document}
share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

The VC manual states that \VCDateISO returns the date as YYYY-MM-DD. If this is the case you can use the following code to extract the three values and set TeX date registers accordantly. Then \today will return this date instead. This should of course happen inside a group.

%\immediate\write18{./vc}
%\input{vc}
\def\VCDateISO{2011-05-24}

\documentclass{article}

\makeatletter
\newcommand\VCDateToday{%
    \expandafter\@VCDateToday\VCDateISO\relax
}
\def\@VCDateToday#1-#2-#3\relax{%
    \begingroup
     \year=#1\relax
     \month=#2\relax
     \day=#3\relax
     \today
    \endgroup
}
\makeatother

\begin{document}

\VCDateToday

\end{document}

I can't test it myself because the VC bundle is not part of TeXLive or MikTeX and I don't want to install it manually just for that.


If you would use svn-multi instead you could simply use \svntoday. Contrary to what the VC documentation says the current version also support binary files.

share|improve this answer
    
This works like I meant it to. Thanks! –  N.N. May 24 '11 at 15:22
add comment

With the isodate package, you can do this fairly simply:

\usepackage[american]{isodate}
\date{\printdate{\VCDateISO}}

Note isodate needs a language to be specified, so if you aren't using babel then you need to call a language option explicitly.

Awkwardly, american and english differ in how they print dates. Calling \usepackage[english]{isodate} changes how the date appears even just with \today.

share|improve this answer
    
This works except there seems to be a comma missing... –  Seamus May 24 '11 at 11:13
    
Yes. This prints "24th May 2011" instead of "May 24, 2011". –  N.N. May 24 '11 at 15:25
    
I think the isodate manual is the best place to check for other possible formats –  Seamus May 24 '11 at 21:11
1  
@N.N. I have edited my solution and it should work exactly as desired now. –  Seamus May 29 '11 at 12:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.