summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/isodate/isodateo.sty
blob: cc9b9439608a0e48fcadf91bd93ad242666458b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
%%
%% This is file `isodateo.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% isodateo.dtx  (with options: `package')
%% 
%%   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
%% 
\def\packagename{isodateo}
\def\fileversion{1.06a}
\def\filedate{2004/02/12}
\def\docdate{2000/08/08}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{isodateo}[\filedate]
\RequirePackage{ifthen}
\RequirePackage{calc}
\IfFileExists{substr.sty}{\RequirePackage{substr}%
 }{\PackageError{isodateo.sty}{Package file substr.sty not found}
   {This version of isodateo.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.}}
\AtBeginDocument{%
  \@ifpackageloaded{babel}{}{%
    \@ifpackageloaded{german}{}{%
      \@ifpackageloaded{ngerman}{}{%
        \let\dateamerican\today%
        \setboolean{isodate@american}{true}%
        \def\iflanguage#1#2#3{\ifthenelse{%
            \equal{#1}{english}\or%
            \equal{#1}{american}\or%
            \equal{#1}{USenglish}%
            }{#2}{#3}}%
        }}}}
\newboolean{isodate@american}%
\DeclareOption{iso}{\AtBeginDocument{\isodate}}
\DeclareOption{num}{\AtBeginDocument{\numdate}}
\DeclareOption{short}{\AtBeginDocument{\shortdate}}
\DeclareOption{TeX}{\AtBeginDocument{\TeXdate}}
\DeclareOption{orig}{\AtBeginDocument{\origdate}}
\ExecuteOptions{orig}
\ProcessOptions
\def\dday{\ifthenelse{\number\day<10}{0}{}\number\day}
\def\dmonth{\ifthenelse{\number\month<10}{0}{}\number\month}
\DeclareRobustCommand*{\num@today}[1]{%
  \iflanguage{german}{\dday.\,\dmonth.#1}{%
    \iflanguage{austrian}{\dday.\,\dmonth.#1}{%
      \iflanguage{ngerman}{\dday.\,\dmonth.#1}{%
        \iflanguage{naustrian}{\dday.\,\dmonth.#1}{%
          \iflanguage{english}{%
            \ifthenelse{\boolean{isodate@american}}{%
              \dmonth/\dday/}{\dday/\dmonth/}}{%
  \dday/\dmonth/}}}}}%
}
\DeclareRobustCommand*{\numdate}{%
  \origdate%
  \setboolean{isodate@american}{false}%
  \iflanguage{american}{\IfCharInString{,}{\today}{%
    \setboolean{isodate@american}{true}}{}}{}%
  \gdef\today{%
    \num@today{~}%
    \number\year}}
\newcounter{yeartwo}
\DeclareRobustCommand*{\shortdate}{%
  \origdate%
  \setboolean{isodate@american}{false}%
  \iflanguage{american}{\IfCharInString{,}{\today}{%
    \setboolean{isodate@american}{true}}{}}{}%
  \gdef\today{%
    \num@today{\,}%
    \setcounter{yeartwo}{\number\year}%
    \whiledo{\theyeartwo>99}{\setcounter{yeartwo}{\theyeartwo-100}}{}%
    \ifthenelse{\number\theyeartwo<10}{0}{}\theyeartwo}}
\DeclareRobustCommand*{\isodate}{%
  \gdef\today{%
    \number\year\iso@isodash%
    \ifthenelse{\number\month<10}{0}{}\number\month\iso@isodash%
    \ifthenelse{\number\day<10}{0}{}\number\day}}
\def\iso@isodash{-}%
\DeclareRobustCommand*{\isodash}[1]{\def\iso@isodash{#1}}%
\DeclareRobustCommand*{\origdate}{\csname date\languagename\endcsname}
\DeclareRobustCommand*{\TeXdate}{%
  \gdef\today{%
    \number\year/%
    \ifthenelse{\number\month<10}{0}{}\number\month/%
    \ifthenelse{\number\day<10}{0}{}\number\day}}
\DeclareRobustCommand*{\iso@printdate}[3]{%
  \begingroup%
  \def\year{#1}%
  \def\month{#2}%
  \def\day{#3}%
  \today%
  \endgroup%
}
\newcounter{iso@slash}
\newcounter{iso@minus}
\newcounter{iso@dot}
\DeclareRobustCommand*{\printdate}[1]{%
  \expandafter\iso@expafterprintdate\expandafter{#1}}%
\DeclareRobustCommand*{\iso@expafterprintdate}[1]{%
  \SubStringsToCounter{iso@slash}{/}{#1}%
  \SubStringsToCounter{iso@minus}{-}{#1}%
  \SubStringsToCounter{iso@dot}{.}{#1}%
  \ifthenelse{\equal{\theiso@dot}{2}}{\printdatenumger{#1}}{%
    \ifthenelse{\equal{\theiso@minus}{2}}{\printdateiso{#1}}{%
      \ifthenelse{\equal{\theiso@slash}{2}}{\printdatenumeng{#1}}{%
        ????\iso@isodash ??\iso@isodash ??%
        \PackageError{isodateo}{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.}%
        }}}}
\DeclareRobustCommand*{\printdateiso}[1]{%
  \expandafter\iso@printdateiso #1\@empty}
\def\iso@printdateiso#1-#2-#3\@empty{\iso@printdate{#1}{#2}{#3}}
\DeclareRobustCommand*{\printdatenumger}[1]{%
  \expandafter\iso@printdatenumger #1\@empty}
\def\iso@printdatenumger#1.#2.#3\@empty{\iso@printdate{#3}{#2}{#1}}
\DeclareRobustCommand*{\printdatenumeng}[1]{%
  \expandafter\iso@printdatenumeng #1\@empty}
\def\iso@printdatenumeng#1/#2/#3\@empty{\iso@printdate{#3}{#2}{#1}}
\DeclareRobustCommand*{\printdateTeX}[1]{%
  \expandafter\iso@printdateTeX\expandafter{#1}}
\DeclareRobustCommand*{\iso@printdateTeX}[1]{%
  \SubStringsToCounter{iso@slash}{/}{#1}%
  \ifthenelse{\equal{\theiso@slash}{2}}%
  {\expandafter\iso@@printdateTeX #1\@empty}{%
    ????\iso@isodash ??\iso@isodash ??%
    \PackageError{isodateo}{unrecognized date format}{Use the format
      yyyy/mm/dd.^^J%
      Don't use any spaces or commands like \protect\, or
      \protect~ inside the argument.}}%
}
\def\iso@@printdateTeX#1/#2/#3\@empty{\iso@printdate{#1}{#2}{#3}}
\endinput
%%
%% End of file `isodateo.sty'.