# Customize displayed time zone with svn-multi and \svnfiledate

When using the svn-multi package together with \svnfiledate it returns

2011-10-05 22:18:31 +0200 (Wed, 05 Oct 2011);

Is there some way of customization to get the following only:

2011-10-05 22:18:31 Time zone;

-

I'm the author of svn-multi. There is currently no feature for this included in the package. I was planning to add something like this for a while and asked the question Handling different time zones here to get some help for the conversation. The code I posted there in my self-answer could be adapted to be used together with \svnfiledate, but I didn't found time to do this yet.

I'm not sure, but checking out all files under Subversion on the local machine should produce all dates in the local time zone. I so, you might have copied the files from a different machine.

Here now the code from the above answer of mine, adapted to \svnfiledate. It prints the following two test lines:

Wednesday 5th October, 2011 21:30 UTC
Wednesday 5th October, 2011 23:30 CEST
Wednesday 5th October, 2011 08:45 -1245


which is the current date in three different time zones. Note that compilation of the adapted date and time might take a while if the day boundary is crossed. This happens inside the datetime package I guess.

I might put this feature into svn-multi, either directly or as an own timezone package.

\documentclass{article}

\usepackage{svn-multi}
\svnidlong
{$HeadURL: file:///tmp/svn/rep/sv.tex$}
{$LastChangedDate: 2011-10-05 23:30:45 +0200 (Wed, 05 Oct 2011)$}
{$LastChangedRevision: 2$}
{$LastChangedBy: martin$}
\usepackage{datenumber}

\makeatletter
\newcommand*\getnumtz[2]{%
\expandafter\@getnumtz\the\numexpr 0#2\relax
\empty\relax\relax\@nnil{#1}{#2}%
}

\def\@getnumtz#1\relax#2\relax#3\@nnil#4#5{%
\ifx\relax#2\relax
\edef#4{#1}%
\else
\begingroup\expandafter\endgroup
\expandafter\let\expandafter#4\csname getnumtz@#5\endcsname%
\fi
}

\newcommand*\definetz[2]{%
\@namedef{getnumtz@#1}{#2}%
}%

\definetz{Z}{+0000}
\definetz{GMT}{+0000}
\definetz{UTC}{+0000}
\definetz{CET}{+0100}
\definetz{CEST}{+0200}

\newcommand*\converttimezone[9]{%
% #1 = macro which receives result
% #2 = year
% #3 = month
% #4 = day
% #5 = hour
% #6 = minute
% #7 = second
% #8 = original timezone
% #9 = target timezone
\begingroup
% Store date:
\c@myyear=\numexpr#2\relax
\c@mymonth=\numexpr#3\relax
\c@myday=\numexpr#4\relax
\c@myhour=\numexpr#5\relax
\c@myminute=\numexpr#6\relax
\c@mysecond=\numexpr#7\relax
% Get numeric timezones
\getnumtz\origtz{#8}%
\getnumtz\targettz{#9}%
% Calculate resulting hour-minute combination (could be improved)
\c@myhourminute=\numexpr (#5)*100+(#6) - \origtz + \targettz \relax
\c@myhour=\numexpr \c@myhourminute / 100\relax% integer devision
\c@myminute=\numexpr \c@myhourminute - \c@myhour*100\relax
\loop\ifnum\c@myminute<\z@
\repeat
\loop\ifnum\c@myminute>59\relax
\repeat
% Check if the day boundary has been crossed and adjust day:
\ifnum\c@myhour<0\relax
\setmydatenumber{mydatenumber}{\value{myyear}}{\value{mymonth}}{\value{myday}}%
\setmydatebynumber{\value{mydatenumber}}{myyear}{mymonth}{myday}%
\else\ifnum\c@myhour>23\relax
\setmydatenumber{mydatenumber}{\value{myyear}}{\value{mymonth}}{\value{myday}}%
\setmydatebynumber{\value{mydatenumber}}{myyear}{mymonth}{myday}%
\fi\fi
\edef\@tempa{\unexpanded{#1}{\themyyear}{\themymonth}{\themyday}{\themyhour}{\themyminute}{\themysecond}{#9}}%
\expandafter
\endgroup\@tempa
}
\newcounter{myhourminute}
\newcounter{myyear}
\newcounter{mymonth}
\newcounter{myday}
\newcounter{myhour}
\newcounter{myminute}
\newcounter{mysecond}
\newcounter{mydatenumber}
\makeatother

\usepackage{datetime}
\newcommand\myshowdate[7]{\formatdate{#3}{#2}{#1} \formattime{#4}{#5}{#6} #7}

\newcommand{\svnfiledateintz}[1]{%
\converttimezone\myshowdate{\svnfileyear}{\svnfilemonth}{\svnfileday}{\svnfilehour}{\svnfileminute}{\svnfilesecond}{\svnfiletimezonehour \svnfiletimezoneminute}{#1}%
}

\begin{document}

\svnfiledateintz{UTC}

\svnfiledateintz{CEST}

\svnfiledateintz{-1245}

\end{document}

-