Debian Codegraph @

texmf-dist/source/latex/datetime2-german/datetime2-german.dtx

raw
1 %\iffalse
2 %<*package>
3 %% \CharacterTable
4 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
5 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
6 %% Digits \0\1\2\3\4\5\6\7\8\9
7 %% Exclamation \! Double quote \" Hash (number) \#
8 %% Dollar \$ Percent \% Ampersand \&
9 %% Acute accent \' Left paren \( Right paren \)
10 %% Asterisk \* Plus \+ Comma \,
11 %% Minus \- Point \. Solidus \/
12 %% Colon \: Semicolon \; Less than \<
13 %% Equals \= Greater than \> Question mark \?
14 %% Commercial at \@ Left bracket \[ Backslash \\
15 %% Right bracket \] Circumflex \^ Underscore \_
16 %% Grave accent \` Left brace \{ Vertical bar \|
17 %% Right brace \} Tilde \~}
18 %</package>
19 %
20 % Doc-Source file to use with LaTeX2e
21 % Copyright (C) 2015 Nicola Talbot, all rights reserved.
22 % Copyright (C) 2017-19 Sebastian Friedl, all rights reserved.
23 % \fi
24 %
25 %
26 %
27 % \changes{1.0}{2015-03-27}{Initial release}
28 % \changes{3.0}{2019-12-13}{Load regionless style only when no regional variant is stated}
29 %
30 % This file contains the style used when German is requested without a known region.
31 %
32 % \medskip
33 % Identify Module.
34 % \begin{macrocode}
35 \ProvidesDateTimeModule{german}[2019/12/13 v3.0]
36 % \end{macrocode}
37 % Require the base German module
38 % \begin{macrocode}
39 \RequireDateTimeModule{german-base}
40 % \end{macrocode}
41 %
42 % Allow the user to configure the "german" and "german-numeric" styles.
43 % The package wide separators such as \cs{dtm@datetimesep} are not used
44 % in case other date formats are also required.
45 %
46 %\begin{macro}{\DTMgermandowdaysep}
47 % The separator between weekday and day.
48 % \begin{macrocode}
49 \newcommand*{\DTMgermandowdaysep}{,\space}
50 % \end{macrocode}
51 %\end{macro}
52 %
53 %\begin{macro}{\DTMgermandaymonthsep}
54 % The separator between the day and month for the text format.
55 % \begin{macrocode}
56 \newcommand*{\DTMgermandaymonthsep}{.\DTMtexorpdfstring{\protect~}{\space}}
57 % \end{macrocode}
58 %\end{macro}
59 %
60 %\begin{macro}{\DTMgermanmonthyearsep}
61 % The separator between the month and year for the text format.
62 % \begin{macrocode}
63 \newcommand*{\DTMgermanmonthyearsep}{\space}
64 % \end{macrocode}
65 %\end{macro}
66 %
67 %\begin{macro}{\DTMgermandatetimesep}
68 % The separator between the date and time blocks in the full format
69 % (either text or numeric).
70 % \begin{macrocode}
71 \newcommand*{\DTMgermandatetimesep}{,\space}
72 % \end{macrocode}
73 %\end{macro}
74 %
75 %\begin{macro}{\DTMgermantimezonesep}
76 % The separator between the time and zone blocks in the full format
77 % (either text or numeric).
78 % \begin{macrocode}
79 \newcommand*{\DTMgermantimezonesep}{\space}
80 % \end{macrocode}
81 %\end{macro}
82 %
83 %\begin{macro}{\DTMgermandatesep}
84 % The separator for the numeric date format.
85 % \begin{macrocode}
86 \newcommand*{\DTMgermandatesep}{.}
87 % \end{macrocode}
88 %\end{macro}
89 %
90 %\begin{macro}{\DTMgermantimesep}
91 % The separator for the numeric time format.
92 % \begin{macrocode}
93 \newcommand*{\DTMgermantimesep}{:}
94 % \end{macrocode}
95 %\end{macro}
96 %
97 % Provide keys that can be used in \cs{DTMlangsetup} to set these separators.
98 % \begin{macrocode}
99 \DTMdefkey{german}{dowdaysep}{\renewcommand*{\DTMgermandowdaysep}{#1}}
100 \DTMdefkey{german}{daymonthsep}{\renewcommand*{\DTMgermandaymonthsep}{#1}}
101 \DTMdefkey{german}{monthyearsep}{\renewcommand*{\DTMgermanmonthyearsep}{#1}}
102 \DTMdefkey{german}{datetimesep}{\renewcommand*{\DTMgermandatetimesep}{#1}}
103 \DTMdefkey{german}{timezonesep}{\renewcommand*{\DTMgermantimezonesep}{#1}}
104 \DTMdefkey{german}{datesep}{\renewcommand*{\DTMgermandatesep}{#1}}
105 \DTMdefkey{german}{timesep}{\renewcommand*{\DTMgermantimesep}{#1}}
106 % \end{macrocode}
107 %
108 %
109 % Define a boolean key that can switch between full and abbreviated formats for
110 % the month and day of week names.
111 % \begin{macrocode}
112 \DTMdefboolkey{german}{abbr}[true]{}
113 % \end{macrocode}
114 %
115 % The default is to show the full names.
116 % \begin{macrocode}
117 \DTMsetbool{german}{abbr}{false}
118 % \end{macrocode}
119 %
120 % Define a boolean key that determines if the time zone mappings
121 % should be used.
122 % \begin{macrocode}
123 \DTMdefboolkey{german}{mapzone}[true]{}
124 % \end{macrocode}
125 % The default is to use mappings.
126 % \begin{macrocode}
127 \DTMsetbool{german}{mapzone}{true}
128 % \end{macrocode}
129 %
130 % Define a boolean key that determines if the day of month should be
131 % displayed.
132 % \begin{macrocode}
133 \DTMdefboolkey{german}{showdayofmonth}[true]{}
134 % \end{macrocode}
135 % The default is to show the day of month.
136 % \begin{macrocode}
137 \DTMsetbool{german}{showdayofmonth}{true}
138 % \end{macrocode}
139 %
140 % Define a boolean key that determines if the year should be
141 % displayed.
142 % \begin{macrocode}
143 \DTMdefboolkey{german}{showyear}[true]{}
144 % \end{macrocode}
145 % The default is to show the year.
146 % \begin{macrocode}
147 \DTMsetbool{german}{showyear}{true}
148 % \end{macrocode}
149 %
150 % Define the (regionless) "german" style.
151 %\changes{1.1}{2017-03-09}{Fixed bug in \cs{DTMDisplaydate}}
152 %\changes{1.2}{2017-09-10}{Implemented short month names}
153 %\changes{1.2}{2017-09-10}{Implemented short weekday names}
154 %\changes{1.2}{2017-09-10}{Implemented day of week}
155 %\changes{2.1}{2017-11-13}{Fixed spurious space when switching languages}
156 % \begin{macrocode}
157 \DTMnewstyle
158 {german}% label
159 {% date style
160 \renewcommand*\DTMdisplaydate[4]{%
161 \ifDTMshowdow
162 \ifnum##4>-1
163 \DTMifbool{german}{abbr}%
164 {\DTMgermanshortweekdayname{##4}}%
165 {\DTMgermanweekdayname{##4}}%
166 \DTMgermandowdaysep
167 \fi
168 \fi
169 %
170 \DTMifbool{german}{showdayofmonth}%
171 {\DTMgermanordinal{##3}\DTMgermandaymonthsep}%
172 {}%
173 %
174 \DTMifbool{german}{abbr}%
175 {\DTMgermanshortmonthname{##2}}%
176 {\DTMgermanmonthname{##2}}%
177 %
178 \DTMifbool{german}{showyear}%
179 {%
180 \DTMgermanmonthyearsep%
181 \number##1 % space intended
182 }%
183 {}%
184 }%
185 \renewcommand*\DTMDisplaydate[4]{%
186 \ifDTMshowdow
187 \ifnum##4>-1
188 \DTMifbool{german}{abbr}%
189 {\DTMgermanshortweekdayname{##4}}%
190 {\DTMgermanweekdayname{##4}}%
191 \DTMgermandowdaysep
192 \fi
193 \fi
194 %
195 \DTMifbool{german}{showdayofmonth}%
196 {\DTMgermanordinal{##3}\DTMgermandaymonthsep}%
197 {}%
198 %
199 \DTMifbool{german}{abbr}%
200 {\DTMgermanshortmonthname{##2}}%
201 {\DTMgermanmonthname{##2}}%
202 %
203 \DTMifbool{german}{showyear}%
204 {%
205 \DTMgermanmonthyearsep%
206 \number##1 % space intended
207 }%
208 {}%
209 }%
210 }%
211 {% time style (use default)
212 \renewcommand*\DTMdisplaytime[3]{%
213 \DTMtwodigits{##1}%
214 \DTMgermantimesep\DTMtwodigits{##2}%
215 \ifDTMshowseconds\DTMgermantimesep\DTMtwodigits{##3}\fi
216 }%
217 }%
218 {% zone style
219 \DTMresetzones
220 \DTMgermanzonemaps
221 \renewcommand*{\DTMdisplayzone}[2]{%
222 \DTMifbool{german}{mapzone}%
223 {\DTMusezonemapordefault{##1}{##2}}%
224 {%
225 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
226 \ifDTMshowzoneminutes\DTMgermantimesep\DTMtwodigits{##2}\fi
227 }%
228 }%
229 }%
230 {% full style
231 \renewcommand*{\DTMdisplay}[9]{%
232 \ifDTMshowdate
233 \DTMdisplaydate{##1}{##2}{##3}{##4}%
234 \DTMgermandatetimesep
235 \fi
236 \DTMdisplaytime{##5}{##6}{##7}%
237 \ifDTMshowzone
238 \DTMgermantimezonesep
239 \DTMdisplayzone{##8}{##9}%
240 \fi
241 }%
242 \renewcommand*{\DTMDisplay}[9]{%
243 \ifDTMshowdate
244 \DTMDisplaydate{##1}{##2}{##3}{##4}%
245 \DTMgermandatetimesep
246 \fi
247 \DTMdisplaytime{##5}{##6}{##7}%
248 \ifDTMshowzone
249 \DTMgermantimezonesep
250 \DTMdisplayzone{##8}{##9}%
251 \fi
252 }%
253 }%
254 % \end{macrocode}
255 %
256 % Define the corresponding numeric style.
257 %\changes{1.2}{2017-09-10}{Implemented day of week}
258 %\changes{2.0}{2017-10-03}{Fixed month-year-separator}
259 % \begin{macrocode}
260 \DTMnewstyle
261 {german-numeric}% label
262 {% date style
263 \renewcommand*\DTMdisplaydate[4]{%
264 \ifDTMshowdow
265 \ifnum##4>-1
266 \DTMifbool{german}{abbr}%
267 {\DTMgermanshortweekdayname{##4}}%
268 {\DTMgermanweekdayname{##4}}%
269 \DTMgermandowdaysep
270 \fi
271 \fi
272 %
273 \DTMifbool{german}{showdayofmonth}%
274 {%
275 \DTMtwodigits{##3}%
276 \DTMgermandatesep
277 }%
278 {}%
279 \DTMtwodigits{##2}%
280 \DTMgermandatesep%
281 \DTMifbool{german}{showyear}%
282 {%
283 \DTMifbool{german}{abbr}%
284 {\DTMtwodigits{##1}}%
285 {\number##1 }% space intended
286 }%
287 {}%
288 }%
289 \renewcommand*{\DTMDisplaydate}[4]{\DTMdisplaydate{##1}{##2}{##3}{##4}}%
290 }%
291 {% time style
292 \renewcommand*\DTMdisplaytime[3]{%
293 \DTMtwodigits{##1}%
294 \DTMgermantimesep\DTMtwodigits{##2}%
295 \ifDTMshowseconds\DTMgermantimesep\DTMtwodigits{##3}\fi
296 }%
297 }%
298 {% zone style
299 \DTMresetzones
300 \DTMgermanzonemaps
301 \renewcommand*{\DTMdisplayzone}[2]{%
302 \DTMifbool{german}{mapzone}%
303 {\DTMusezonemapordefault{##1}{##2}}%
304 {%
305 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
306 \ifDTMshowzoneminutes\DTMgermantimesep\DTMtwodigits{##2}\fi
307 }%
308 }%
309 }%
310 {% full style
311 \renewcommand*{\DTMdisplay}[9]{%
312 \ifDTMshowdate
313 \DTMdisplaydate{##1}{##2}{##3}{##4}%
314 \DTMgermandatetimesep
315 \fi
316 \DTMdisplaytime{##5}{##6}{##7}%
317 \ifDTMshowzone
318 \DTMgermantimezonesep
319 \DTMdisplayzone{##8}{##9}%
320 \fi
321 }%
322 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
323 }
324 % \end{macrocode}
325 %
326 % Switch the style according to the \opt{useregional} setting.
327 % \begin{macrocode}
328 \DTMifcaseregional
329 {}% do nothing
330 {\DTMsetstyle{german}}
331 {\DTMsetstyle{german-numeric}}
332 % \end{macrocode}
333 %
334 % Redefine \cs{dategerman} (or \cs{date}\meta{dialect}) to prevent
335 % \sty{babel} from resetting \cs{today}. (For this to work,
336 % \sty{babel} must already have been loaded if it's required.)
337 % \begin{macrocode}
338 \ifcsundef{date\CurrentTrackedDialect}
339 {%
340 \ifundef\dategerman
341 {% do nothing
342 }%
343 {%
344 \def\dategerman{%
345 \DTMifcaseregional
346 {}% do nothing
347 {\DTMsetstyle{german}}%
348 {\DTMsetstyle{german-numeric}}%
349 }%
350 }%
351 }%
352 {%
353 \csdef{date\CurrentTrackedDialect}{%
354 \DTMifcaseregional
355 {}% do nothing
356 {\DTMsetstyle{german}}%
357 {\DTMsetstyle{german-numeric}}%
358 }%
359 }%
360 % \end{macrocode}
361 %
362 \endinput