% \two@digits is supplied by LaTeX.

\newcommand{\isodate}
  {\number\year-\two@digits\month-\two@digits\day}

\newcommand{\isotime}
  {\begingroup
     \count0=\time
     \divide\count0 by 60\relax
     \count1=-\count0\relax
     \multiply\count1 by 60\relax
     \advance\count1 by \time
     \two@digits{\count0}:%
     \two@digits{\count1}\relax
   \endgroup}

\renewcommand{\today}{\isodate}

\DeclareOption{todaytime}{\renewcommand{\today}{\isodate T\isotime}}
\ProcessOptions

% ======================================================================
% There are three algorithms in the teTeX distribution for calculating
% the hours and minutes from \time.
%
% To describe all of the algorithms, we assume these declarations:
%
%   \newcount\h
%   \newcount\m
%
% We assume that the desired printout format is HHMM, where HH are two
% decimal digits describing the hour and MM are two decimal digits
% describing the minutes.

% from {plain/{base/testfont,misc/{list,llist,mproof,wlist}},latex/base/nfssfont}.tex
%
% To put the hours in \h and the minutes in \m:
%
%   \h=\time \divide\h 60
%   \m=-\h \multiply\m 60 \advance\m \time
%
% To print out the hours from \h and minutes from \m
%
%   \def\twodigits#1{\ifnum #1<10 0\fi \number#1}
%
%   \twodigits\h\twodigits\m

% from latex/koma-script/scrtime.sty
%
% To put the hours in \h and the minutes in \h:
%
%   \h=\time \divide\h 60 \multiply\h 60
%   \m=\time \advance\m-\h
%   \divide\h 60
%
% To print out the hours from \h and minutes from \m
%
%   \def\twodigits#1{\ifnum #1<10 0\fi\the#1}
%
%   \twodigits\h\twodigits\m

% from plain/base/gkpmac.tex
%
% To put the hours and minutes into \m so that when viewed as a
% decimal number, the value of \m reads as 1HHMM:
%
%   \m=\time \divide\m 60
%   \multiply\m 40 \advance\m\time
%   \advance\m 10000
%
% To print out the hours and the minutes when \m contains a decimal
% number whose digits read as 1HHMM:
%
%   \def\gobbleone1{}
%
%   \expandafter\gobbleone\number\m\relax
