%save as e.g. 01-Ziegenhagen-2007-12-31.tex
\documentclass{article}

\begin{filecontents}{jobdate.sty}
%begin of jobdate.sty
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{jobdate}[2008/01/01 v. 0.2 extracts date and invoice number from jobname (UZ)] 

%Author: Uwe Ziegenhagen
% based on code supplied by Friedrich Vosberg and Markus Kohm
% see posting <3983639.NRU96H2Y1Y@ID-107054.user.dfncis.de>
% requires the filename to be of the following form
% no-id-YYYY-MM-DD

\makeatletter

\newcommand{\getdatefromjobname}{%
\getdayfromjobname.\getmonthfromjobname.\getyearfromjobname
}

\newcommand*{\getnumberfromjobname}{%
  \expandafter\@getnumberfromfilename\jobname--\@nil%
}

\newcommand*{\getdayfromjobname}{%
  \expandafter\@getdayfromfilename\jobname\@nil%
}

\newcommand*{\getmonthfromjobname}{%
  \expandafter\@getmonthfromfilename\jobname--\@nil%
}

\newcommand*{\getidfromjobname}{%
  \expandafter\@getidfromfilename\jobname--\@nil%
}

\newcommand*{\getyearfromjobname}{%
  \expandafter\@getyearfromfilename\jobname--\@nil%
}

\newcommand*\@getnumberfromfilename{}
\def\@getnumberfromfilename#1-#2-\@nil{%
  \begingroup
    \setlength{\@tempdima}{#1pt}%
  \endgroup
  #1%
} 

\newcommand*\@getdayfromfilename{}
\def\@getdayfromfilename#1-#2-#3-#4-#5\@nil{%
  \begingroup
    \setlength{\@tempdima}{#1pt}%
  \endgroup
  #5%
} 

\newcommand*\@getidfromfilename{}
\def\@getidfromfilename#1-#2-#3-#4-#5\@nil{%
  \begingroup
    \setlength{\@tempdima}{#1pt}%
  \endgroup
  #2%
} 

\newcommand*\@getmonthfromfilename{}
\def\@getmonthfromfilename#1-#2-#3-#4-#5\@nil{%
  \begingroup
    \setlength{\@tempdima}{#1pt}%
  \endgroup
  #4%
} 

\newcommand*\@getyearfromfilename{}
\def\@getyearfromfilename#1-#2-#3-#4-#5\@nil{%
  \begingroup
    \setlength{\@tempdima}{#1pt}%
  \endgroup
  #3%
} 

\makeatother
% end of jobdate.sty
\end{filecontents}

\usepackage{jobdate}

\date{\getdatefromjobname}
\author{Uwe Ziegenhagen}
\title{Jobdate Description}

\begin{document}
\maketitle

\noindent Using \texttt{jobdate.sty} one can easily extract information from the filename, if it follows a certain form. The LaTeX command \verb|\|jobname returns the name of the LaTeX file. If we have the filename follow a certain structure we can easily extract certain tokens that can be used inside the document. In the current form the package expects the filename to be of the form \texttt{no-id-YYYY-MM-DD} and offers the following commands:

\begin{itemize}
	\item \verb|\|getidfromjobname: \getidfromjobname
	\item \verb|\|getnumberfromjobname: \getnumberfromjobname
	\item \verb|\|getdayfromjobname: \getdayfromjobname
	\item \verb|\|getmonthfromjobname: \getmonthfromjobname
	\item \verb|\|getyearfromjobname: \getyearfromjobname
	\item \verb|\|getdatefromjobname: \getdatefromjobname
\end{itemize}
\end{document}
