summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/isodate/isodate.sty
blob: 8d6313581993c744dc9efc37d436461d5552611a (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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
%%
%% 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/04/15  v2.28  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{cleanlook}{\AtEndOfPackage{\cleanlookdateon}}
\DeclareOption{nocleanlook}{\AtEndOfPackage{\cleanlookdateoff}}
\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{italian}{\input{italian.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,nocleanlook}
\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
\newif\ifiso@cleanlook
\DeclareRobustCommand*\cleanlookdateon{\iso@cleanlooktrue}
\DeclareRobustCommand*\cleanlookdateoff{\iso@cleanlookfalse}
\cleanlookdateoff
\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\MessageBreak
        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\MessageBreak
        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\MessageBreak
        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'.