%%
%% This is file `isodate.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% isodate.dtx  (with options: `isodate')
%% 
%%   isodate package
%% 
%%   Copyright  2000--2005 Harald Harders
%% 
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1 of the License, or any later version.
%% 
%%   h.harders@tu-bs.de
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{isodate}
  [2005/03/11  v2.27  Print dates with different formats (HH)]
\RequirePackage{ifthen}
\IfFileExists{substr.sty}{\RequirePackage{substr}%
 }{\PackageError{isodate.sty}{Package file substr.sty not found}
   {This version of isodate.sty needs the package substr.sty.^^J%
     You can download it from
     CTAN:/macros/latex/contrib/substr/^^J%
     e.g., one CTAN node is ftp.dante.de.
     Install substr.sty into your TeX tree.}}
\DeclareOption{iso}{\AtEndOfPackage{\isodate}}
\DeclareOption{num}{\AtEndOfPackage{\numdate}}
\DeclareOption{short}{\AtEndOfPackage{\shortdate}}
\DeclareOption{TeX}{\AtEndOfPackage{\TeXdate}}
\DeclareOption{orig}{\AtEndOfPackage{\origdate}}
\DeclareOption{shortorig}{\AtEndOfPackage{\shortorigdate}}
\DeclareOption{Roman}{\AtEndOfPackage{\Romandate}}
\DeclareOption{roman}{\AtEndOfPackage{\romandate}}
\DeclareOption{shortRoman}{\AtEndOfPackage{\shortRomandate}}
\DeclareOption{shortroman}{\AtEndOfPackage{\shortromandate}}
\DeclareOption{inputenglish}{\AtEndOfPackage{\dateinputformat{english}}}
\DeclareOption{inputbritish}{\AtEndOfPackage{\dateinputformat{english}}}
\DeclareOption{inputUKenglish}{\AtEndOfPackage{\dateinputformat{english}}}
\DeclareOption{inputamerican}{\AtEndOfPackage{\dateinputformat{american}}}
\DeclareOption{inputUSenglish}{\AtEndOfPackage{\dateinputformat{american}}}
\DeclareOption{inputtex}{\AtEndOfPackage{\dateinputformat{tex}}}
\DeclareOption{inputTeX}{\AtEndOfPackage{\dateinputformat{tex}}}
\DeclareOption{inputlatex}{\AtEndOfPackage{\dateinputformat{tex}}}
\DeclareOption{inputLaTeX}{\AtEndOfPackage{\dateinputformat{tex}}}
\DeclareOption{american}{\input{english.idf}}
\DeclareOption{australian}{\input{english.idf}}
\DeclareOption{austrian}{\input{german.idf}}
\DeclareOption{danish}{\input{danish.idf}}
\DeclareOption{english}{\input{english.idf}}
\DeclareOption{british}{\input{english.idf}}
\DeclareOption{french}{\input{french.idf}}
\DeclareOption{frenchb}{\input{french.idf}}
\DeclareOption{german}{\input{german.idf}}
\DeclareOption{naustrian}{\input{german.idf}}
\DeclareOption{newzealand}{\input{english.idf}}
\DeclareOption{ngerman}{\input{german.idf}}
\DeclareOption{norsk}{\input{norsk.idf}}
\DeclareOption{norwegian}{\input{norsk.idf}}
\DeclareOption{swedish}{\input{swedish.idf}}
\DeclareOption{UKenglish}{\input{english.idf}}
\DeclareOption{USenglish}{\input{english.idf}}
\DeclareOption*{%
  \InputIfFileExists{\CurrentOption.idf}{}{%
    \PackageError{isodate}{%
      Isodate definition file \CurrentOption.idf not found}{%
      Maybe you misspelled the language option?}}%
  }
\ExecuteOptions{orig}
\ProcessOptions*
\ifx\iso@languageloaded\@undefined
  \PackageError{isodate}{%
    You haven't specified a language option}{%
    You need to specify a language, either as a global
    option\MessageBreak
    or as an optional argument to the \string\usepackage\space
    command.\MessageBreak
    If you have used the old isodate package (version <=1.06) you can
    change the\MessageBreak
    usepackage command to \protect\usepackage{isodate}.\MessageBreak
    You shouldn't try to proceed from here, type x to quit.}
\fi
\newcommand*\iso@printday[1]{%
  \ifisotwodigitday
    \ifthenelse{\number#1<10}{0}{}%
  \fi
  \number#1%
}%
\newcommand*\twodigitarabic[1]{%
  \ifthenelse{\number\arabic{#1}<10}{0}{}%
  \arabic{#1}%
}
\newcommand*\iso@printmonth[1]{%
  \setcounter{iso@tmpmonth}{#1}%
  \theiso@tmpmonth%
}
\newcounter{iso@tmpmonth}
\newcounter{iso@yeartwo}%
\newcommand*\iso@yeartwo[1]{%
  \setcounter{iso@yeartwo}{\number#1}%
  \whiledo{\theiso@yeartwo>99}{%
    \addtocounter{iso@yeartwo}{-100}}{}%
  \ifthenelse{\number\theiso@yeartwo<10}{0}{}\theiso@yeartwo
}
\newcommand*\iso@yearfour[1]{%
  \ifthenelse{\number#1<1000}{0}{}%
  \ifthenelse{\number#1<100}{0}{}%
  \ifthenelse{\number#1<10}{0}{}%
  \number#1%
}%
\newif\ifisotwodigitday
\def\iso@dateformat{numeric}
\DeclareRobustCommand*\dateinputformat[1]{%
  \ifthenelse{%
    \equal{#1}{english}\or
    \equal{#1}{british}\or
    \equal{#1}{UKenglish}}{%
    \def\iso@inputformat{english}%
  }{%
    \ifthenelse{%
      \equal{#1}{american}\or
      \equal{#1}{USenglish}}{%
      \def\iso@inputformat{american}%
    }{%
      \ifthenelse{%
        \equal{#1}{tex}\or
        \equal{#1}{TeX}\or
        \equal{#1}{latex}\or
        \equal{#1}{LaTeX}}{%
        \def\iso@inputformat{tex}%
      }{%
        \PackageError{isodate}{Invalid date input format}{%
          Maybe you misspelled the language option (english, american,
          tex)?}%
      }%
    }%
  }%
}
\dateinputformat{english}
\DeclareRobustCommand*\numdate[1][twodigitarabic]{%
  \def\iso@dateformat{numeric}%
  \isotwodigitdaytrue
  \def\theiso@tmpmonth{\csname #1\endcsname{iso@tmpmonth}}%
}
\DeclareRobustCommand*\shortdate[1][twodigitarabic]{%
  \def\iso@dateformat{short}%
  \isotwodigitdaytrue
  \def\theiso@tmpmonth{\csname #1\endcsname{iso@tmpmonth}}%
}
\DeclareRobustCommand*\isodate[1][twodigitarabic]{%
  \def\iso@dateformat{iso}%
  \isotwodigitdaytrue
  \def\theiso@tmpmonth{\csname #1\endcsname{iso@tmpmonth}}%
}
\DeclareRobustCommand*\origdate{%
  \def\iso@dateformat{orig}%
  \isotwodigitdayfalse
  \def\theiso@tmpmonth{\twodigitarabic{iso@tmpmonth}}%
}
\DeclareRobustCommand*\shortorigdate{%
  \def\iso@dateformat{shortorig}%
  \isotwodigitdayfalse
  \def\theiso@tmpmonth{\twodigitarabic{iso@tmpmonth}}%
}
\DeclareRobustCommand*\TeXdate[1][twodigitarabic]{%
  \def\iso@dateformat{TeX}%
  \isotwodigitdaytrue
  \def\theiso@tmpmonth{\csname #1\endcsname{iso@tmpmonth}}%
}
\DeclareRobustCommand*\Romandate{%
  \numdate[Roman]%
  \isotwodigitdayfalse
}
\DeclareRobustCommand*\romandate{%
  \numdate[roman]%
  \isotwodigitdayfalse
}
\DeclareRobustCommand*\shortRomandate{%
  \shortdate[Roman]%
  \isotwodigitdayfalse
}
\DeclareRobustCommand*\shortromandate{%
  \shortdate[roman]%
  \isotwodigitdayfalse
}
\def\iso@isodash{-}%
\DeclareRobustCommand*\isodash[1]{\def\iso@isodash{#1}}%
\def\iso@twodigitsign{}
\DeclareRobustCommand*\shortyearsign[1]{\def\iso@twodigitsign{#1}}%
\def\iso@rangesign{\csname iso@rangesign@\iso@languagename\endcsname}%
\DeclareRobustCommand*\isorangesign[1]{\def\iso@rangesign{#1}}%
\newif\ifiso@printyear
\DeclareRobustCommand*\printyearon{\iso@printyeartrue}
\DeclareRobustCommand*\printyearoff{\iso@printyearfalse}
\printyearon
\newcommand*\iso@printdate[3]{%
  \begingroup%
    \@ifundefined{iso@printdate@\iso@languagename}{%
      \PackageWarning{isodate}{Language \iso@languagename\space unknown
        to isodate.\MessageBreak
        Using default format.}%
    }{}%
    \year=#1 %
    \month=#2 %
    \day=#3 %
    \today%
  \endgroup%
}
\DeclareRobustCommand*\printdate[1]{%
  \edef\iso@date{#1}%
  \SubStringsToCounter{iso@slash}{/}{\iso@date}%
  \SubStringsToCounter{iso@minus}{-}{\iso@date}%
  \SubStringsToCounter{iso@dot}{.}{\iso@date}%
  \ifthenelse{\equal{\theiso@dot}{2}}{%
    \expandafter\iso@input@german\iso@date\@empty}{%
    \ifthenelse{\equal{\theiso@minus}{2}}{%
      \expandafter\iso@input@iso\iso@date\@empty}{%
      \ifthenelse{\equal{\theiso@slash}{2}}{%
        \expandafter\iso@input@english\iso@date\@empty}{%
        ????\iso@isodash ??\iso@isodash ??%
        \PackageError{isodate}{unrecognized date format}{Use one of
          the following formats as macro argument:^^J%
          \space\space dd.mm.yyyy^^J%
          \space\space dd/mm/yyyy^^J%
          \space\space yyyy-mm-dd^^J%
          Don't use any spaces or commands like \protect\, or
          \protect~ inside the argument.}%
        }}}%
}
\def\iso@input@iso#1-#2-#3\@empty{\iso@printdate{#1}{#2}{#3}}
\def\iso@input@german#1.#2.#3\@empty{\iso@printdate{#3}{#2}{#1}}
\def\iso@input@english#1/#2/#3\@empty{%
  \ifthenelse{\equal{\iso@inputformat}{tex}}{%
    \iso@printdate{#1}{#2}{#3}%
  }{%
    \ifthenelse{\equal{\iso@inputformat}{american}}{%
      \iso@printdate{#3}{#1}{#2}%
    }{%
      \iso@printdate{#3}{#2}{#1}%
    }%
  }%
}
\DeclareRobustCommand*\printdateTeX[1]{%
  \edef\iso@date{#1}%
  \SubStringsToCounter{iso@slash}{/}{\iso@date}%
  \ifthenelse{\equal{\theiso@slash}{2}}{%
    \expandafter\iso@input@TeX\iso@date\@empty}{%
    ????\iso@isodash ??\iso@isodash ??%
    \PackageError{isodate}{unrecognized date format}{Use one of
      the following formats as macro argument:^^J%
      \space\space dd.mm.yyyy^^J%
      \space\space dd/mm/yyyy^^J%
      \space\space yyyy-mm-dd^^J%
      Don't use any spaces or commands like \protect\, or
      \protect~ inside the argument.}%
    }}
\def\iso@input@TeX#1/#2/#3\@empty{\iso@printdate{#1}{#2}{#3}}
\DeclareRobustCommand*\daterange[2]{%
  \edef\iso@date{#1}%
  \edef\iso@@date{#2}%
  \edef\iso@@@date{\iso@date,\iso@@date}%
  \SubStringsToCounter{iso@slash}{/}{\iso@date}%
  \SubStringsToCounter{iso@minus}{-}{\iso@date}%
  \SubStringsToCounter{iso@dot}{.}{\iso@date}%
  \SubStringsToCounter{iso@@slash}{/}{\iso@@date}%
  \SubStringsToCounter{iso@@minus}{-}{\iso@@date}%
  \SubStringsToCounter{iso@@dot}{.}{\iso@@date}%
  \ifthenelse{\equal{\theiso@dot}{2}\and\equal{\theiso@@dot}{2}}{%
    \expandafter\iso@range@input@german\iso@@@date\@empty}{%
    \ifthenelse{\equal{\theiso@minus}{2}\and\equal{\theiso@@minus}{2}}{%
      \expandafter\iso@range@input@iso\iso@@@date\@empty}{%
      \ifthenelse{\equal{\theiso@slash}{2}\and%
                  \equal{\theiso@@slash}{2}}{%
        \expandafter\iso@range@input@english\iso@@@date\@empty}{%
        ????\iso@isodash ??\iso@isodash ??%
        \PackageError{isodate}{unrecognized date format}{Use one of
          the following formats as macro argument:^^J%
          \space\space dd.mm.yyyy^^J%
          \space\space dd/mm/yyyy^^J%
          \space\space yyyy-mm-dd^^J%
          Don't use any spaces or commands like \protect\, or
          \protect~ inside the argument.^^J
          Use the same format for both arguments.}%
        }}}%
}
\def\iso@range@input@iso#1-#2-#3,#4-#5-#6\@empty{%
  \begingroup
    \@ifundefined{iso@daterange@\iso@languagename}{%
      \PackageWarning{isodate}{Language \iso@languagename\space unknown
        to isodate.\MessageBreak
        Using default date range with range sign --.}%
        \expandafter\def\csname iso@printdate@\iso@languagename\endcsname{}%
      \iso@printdate{#1}{#2}{#3}--\iso@printdate{#4}{#5}{#6}%
    }{%
      \ifthenelse{\equal{\number#1}{\number#4}}{}{\printyearon}%
      \csname iso@daterange@\iso@languagename\endcsname{%
        #1}{#2}{#3}{#4}{#5}{#6}%
    }%
  \endgroup
}
\def\iso@range@input@german#1.#2.#3,#4.#5.#6\@empty{%
  \begingroup
    \@ifundefined{iso@daterange@\iso@languagename}{%
      \PackageWarning{isodate}{Language \iso@languagename\space unknown
        to isodate.\MessageBreak
        Using default date range with range sign --.}%
        \expandafter\def\csname iso@printdate@\iso@languagename\endcsname{}%
      \iso@printdate{#3}{#2}{#1}--\iso@printdate{#6}{#5}{#4}%
    }{%
      \ifthenelse{\equal{\number#3}{\number#6}}{}{\printyearon}%
      \csname iso@daterange@\iso@languagename\endcsname{%
        #3}{#2}{#1}{#6}{#5}{#4}%
    }%
  \endgroup
}
\def\iso@range@input@english#1/#2/#3,#4/#5/#6\@empty{%
  \begingroup
    \@ifundefined{iso@daterange@\iso@languagename}{%
      \PackageWarning{isodate}{Language \iso@languagename\space unknown
        to isodate.\MessageBreak
        Using default date range with range sign --.}%
        \expandafter\def\csname iso@printdate@\iso@languagename\endcsname{}%
        \ifthenelse{\equal{\iso@inputformat}{tex}}{%
          \iso@printdate{#1}{#2}{#3}--\iso@printdate{#4}{#5}{#6}%
        }{%
          \ifthenelse{\equal{\iso@inputformat}{american}}{%
            \iso@printdate{#3}{#1}{#2}--\iso@printdate{#6}{#4}{#5}%
          }{%
            \iso@printdate{#3}{#2}{#1}--\iso@printdate{#6}{#5}{#4}%
          }%
        }%
    }{%
      \ifthenelse{\equal{\number#3}{\number#6}}{}{\printyearon}%
      \ifthenelse{\equal{\iso@inputformat}{tex}}{%
        \csname iso@daterange@\iso@languagename\endcsname{%
          #1}{#2}{#3}{#4}{#5}{#6}%
      }{%
        \ifthenelse{\equal{\iso@inputformat}{american}}{%
          \csname iso@daterange@\iso@languagename\endcsname{%
            #3}{#1}{#2}{#6}{#4}{#5}%
        }{%
          \csname iso@daterange@\iso@languagename\endcsname{%
            #3}{#2}{#1}{#6}{#5}{#4}%
        }%
      }%
    }%
  \endgroup
}
\newcounter{iso@slash}
\newcounter{iso@minus}
\newcounter{iso@dot}
\newcounter{iso@@slash}
\newcounter{iso@@minus}
\newcounter{iso@@dot}
\AtBeginDocument{%
  \@tempswafalse
  \@ifpackageloaded{babel}{%
    \@tempswatrue
    \typeout{isodate: babel.sty has been loaded}%
  }{}%
  \@ifpackageloaded{german}{%
    \@tempswatrue
    \typeout{isodate: german.sty has been loaded}%
  }{}%
  \@ifpackageloaded{ngerman}{%
    \@tempswatrue
    \typeout{isodate: ngerman.sty has been loaded}%
  }{}%
  \if@tempswa
    \gdef\iso@languagename{\languagename}%
    \edef\iso@tmplang{\languagename}%
    \expandafter\selectlanguage\expandafter{\iso@tmplang}%
  \else
    \typeout{isodate: babel.sty, (n)german.sty have not been loaded}%
    \csname date\iso@languagename\endcsname%
  \fi
}
\endinput
%%
%% End of file `isodate.sty'.
