Debian Codegraph @

texmf-dist/source/latex/datetime2-latin/datetime2-latin.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 %\fi
20 % \iffalse
21 % Doc-Source file to use with LaTeX2e
22 % Copyright (C) 2018 Nicola Talbot, all rights reserved.
23 % (New maintainer add relevant lines here.)
24 % \fi
25 % \iffalse
26 %<*driver>
27 \documentclass{ltxdoc}
28
29 \usepackage{alltt}
30 \usepackage{graphicx}
31 \usepackage[utf8]{inputenc}
32 \usepackage[T1]{fontenc}
33 \usepackage[colorlinks,
34 bookmarks,
35 hyperindex=false,
36 pdfauthor={Nicola L.C. Talbot},
37 pdftitle={datetime2.sty Latin Module}]{hyperref}
38
39
40 \CheckSum{212}
41
42 \renewcommand*{\usage}[1]{\hyperpage{#1}}
43 \renewcommand*{\main}[1]{\hyperpage{#1}}
44 \IndexPrologue{\section*{\indexname}\markboth{\indexname}{\indexname}}
45 \setcounter{IndexColumns}{2}
46
47 \newcommand*{\sty}[1]{\textsf{#1}}
48 \newcommand*{\opt}[1]{\texttt{#1}\index{#1=\texttt{#1}|main}}
49
50 \RecordChanges
51 \PageIndex
52 \CodelineNumbered
53
54 \begin{document}
55 \DocInput{datetime2-latin.dtx}
56 \end{document}
57 %</driver>
58 %\fi
59 %
60 %\MakeShortVerb{"}
61 %
62 %\title{Latin Module for datetime2 Package}
63 %\author{Nicola L. C. Talbot (inactive)}
64 %\date{2018-05-18 (v1.1)}
65 %\maketitle
66 %
67 %This module is currently unmaintained and may be subject to change.
68 %If you want to volunteer to take over maintanance, contact me at
69 %\url{http://www.dickimaw-books.com/contact.html}
70 %
71 %\begin{abstract}
72 %This is the Latin language module for the \sty{datetime2}
73 %package. If you want to use the settings in this module you must
74 %install it in addition to installing \sty{datetime2}. If you use
75 %\sty{babel} or \sty{polyglossia}, you will need this module to
76 %prevent them from redefining \cs{today}. The \sty{datetime2}
77 % \opt{useregional} setting must be set to "text" or "numeric"
78 % for the language styles to be set.
79 % Alternatively, you can set the style in the document using
80 % \cs{DTMsetstyle}, but this may be changed by \cs{date}\meta{language}
81 % depending on the value of the \opt{useregional} setting.
82 %\end{abstract}
83 %
84 %I've copied the date style from \texttt{babel-latin}'s \cs{today}.
85 %This is different from \sty{polyglossia}'s Latin \cs{today} so
86 %there's a check to see if \sty{polyglossia} has been loaded to make
87 %the styles match.
88 %
89 %I don't know if these settings are correct.
90 %In particular, I don't know if the "latin" time style is
91 %correct. Currently this just uses the "default" time style. Please
92 %be aware that this may change. Whoever takes over maintanance
93 %of this module may can change it as appropriate.
94 %
95 %The new maintainer should add the line:
96 %\begin{verbatim}
97 % The Current Maintainer of this work is Name.
98 %\end{verbatim}
99 %to the preamble part in \texttt{datetime2-latin.ins} where Name
100 %is the name of the maintainer(s) and replace
101 %the `inactive' status to `maintained'.
102 %
103 %Currently there is only a regionless style.
104 %
105 %\StopEventually{%
106 %\clearpage
107 %\phantomsection
108 %\addcontentsline{toc}{section}{Change History}%
109 %\PrintChanges
110 %\addcontentsline{toc}{section}{\indexname}%
111 %\PrintIndex}
112 %\section{The Code}
113 %At the moment there is only the one ".ldf" file.
114 %
115 %\subsection{Main Latin Module (\texttt{datetime2-latin.ldf})}
116 %\changes{1.0}{2015-03-31}{Initial release}
117 %
118 %\iffalse
119 % \begin{macrocode}
120 %<*datetime2-latin.ldf>
121 % \end{macrocode}
122 %\fi
123 %
124 % Identify Module
125 % \begin{macrocode}
126 \ProvidesDateTimeModule{latin}[2018/05/18 v1.1]
127 % \end{macrocode}
128 %
129 %\begin{macro}{\DTMlatindatefont}
130 %\sty{polyglossia} version doesn't implement a font change.
131 % \begin{macrocode}
132 \@ifpackageloaded{polyglossia}
133 {
134 \newcommand*{\DTMlatindayfont}[1]{#1}
135 }
136 {
137 % \end{macrocode}
138 %This will need protecting.
139 % \begin{macrocode}
140 \newcommand*{\DTMlatindayfont}[1]{%
141 {\check@mathfonts\fontsize\sf@size\z@\math@fontsfalse\selectfont#1}%
142 }
143 }
144 % \end{macrocode}
145 %\end{macro}
146 %
147 %\begin{macro}{\DTMlatinordinal}
148 % \begin{macrocode}
149 \newcommand*{\DTMlatinordinal}[1]{%
150 \DTMtexorpdfstring
151 {%
152 \protect\DTMlatindayfont{\uppercase\expandafter{\romannumeral#1}}%
153 }%
154 {\romannumeral#1 }%
155 }
156 % \end{macrocode}
157 %\end{macro}
158 %
159 %\begin{macro}{\DTMlatinyear}
160 % \begin{macrocode}
161 \newcommand*{\DTMlatinyear}[1]{%
162 \DTMtexorpdfstring
163 {%
164 \uppercase\expandafter{\romannumeral#1}%
165 }%
166 {\romannumeral#1 }%
167 }
168 % \end{macrocode}
169 %\end{macro}
170 %
171 %\begin{macro}{\DTMlatinmonthname}
172 % Latin month names.
173 % \begin{macrocode}
174 \@ifpackageloaded{polyglossia}
175 {
176 % \end{macrocode}
177 % Match \sty{polyglossia} month names:
178 % \begin{macrocode}
179 \newcommand*{\DTMlatinmonthname}[1]{%
180 \ifcase#1
181 \or
182 Januarii%
183 \or
184 Februarii%
185 \or
186 Martii%
187 \or
188 Aprilis%
189 \or
190 Maji%
191 \or
192 Junii%
193 \or
194 Julii%
195 \or
196 Augusti%
197 \or
198 Septembris%
199 \or
200 Octobris%
201 \or
202 Novembris%
203 \or
204 Decembris%
205 \fi
206 }
207 }
208 {
209 % \end{macrocode}
210 % Match \sty{babel} month names:
211 % \begin{macrocode}
212 \newcommand*{\DTMlatinmonthname}[1]{%
213 \ifcase#1
214 \or
215 Ianuarii%
216 \or
217 Februarii%
218 \or
219 Martii%
220 \or
221 Aprilis%
222 \or
223 Maii%
224 \or
225 Iunii%
226 \or
227 Iulii%
228 \or
229 Augusti%
230 \or
231 Septembris%
232 \or
233 Octobris%
234 \or
235 Novembris%
236 \or
237 Decembris%
238 \fi
239 }
240 }
241 % \end{macrocode}
242 %\end{macro}
243 %
244 %
245 % Define the \texttt{latin} style.
246 % The time style is the same as the "default" style
247 % provided by \sty{datetime2}. This may need correcting.
248 %
249 % Allow the user a way of configuring the "latin" and
250 % "latin-numeric" styles. This doesn't use the package wide
251 % separators such as
252 % \cs{dtm@datetimesep} in case other date formats are also required.
253 %\begin{macro}{\DTMlatindaymonthsep}
254 % The separator between the day and month for the text format.
255 % \begin{macrocode}
256 \newcommand*{\DTMlatindaymonthsep}{\space}
257 % \end{macrocode}
258 %\end{macro}
259 %
260 %\begin{macro}{\DTMlatinmonthyearsep}
261 % The separator between the month and year for the text format.
262 % \begin{macrocode}
263 \newcommand*{\DTMlatinmonthyearsep}{\space}
264 % \end{macrocode}
265 %\end{macro}
266 %
267 %\begin{macro}{\DTMlatindatetimesep}
268 % The separator between the date and time blocks in the full format
269 % (either text or numeric).
270 % \begin{macrocode}
271 \newcommand*{\DTMlatindatetimesep}{\space}
272 % \end{macrocode}
273 %\end{macro}
274 %
275 %\begin{macro}{\DTMlatintimezonesep}
276 % The separator between the time and zone blocks in the full format
277 % (either text or numeric).
278 % \begin{macrocode}
279 \newcommand*{\DTMlatintimezonesep}{\space}
280 % \end{macrocode}
281 %\end{macro}
282 %
283 %\begin{macro}{\DTMlatindatesep}
284 % The separator for the numeric date format.
285 % \begin{macrocode}
286 \newcommand*{\DTMlatindatesep}{/}
287 % \end{macrocode}
288 %\end{macro}
289 %
290 %\begin{macro}{\DTMlatintimesep}
291 % The separator for the numeric time format.
292 % \begin{macrocode}
293 \newcommand*{\DTMlatintimesep}{:}
294 % \end{macrocode}
295 %\end{macro}
296 %
297 %Provide keys that can be used in \cs{DTMlangsetup} to set these
298 %separators.
299 % \begin{macrocode}
300 \DTMdefkey{latin}{daymonthsep}{\renewcommand*{\DTMlatindaymonthsep}{#1}}
301 \DTMdefkey{latin}{monthyearsep}{\renewcommand*{\DTMlatinmonthyearsep}{#1}}
302 \DTMdefkey{latin}{datetimesep}{\renewcommand*{\DTMlatindatetimesep}{#1}}
303 \DTMdefkey{latin}{timezonesep}{\renewcommand*{\DTMlatintimezonesep}{#1}}
304 \DTMdefkey{latin}{datesep}{\renewcommand*{\DTMlatindatesep}{#1}}
305 \DTMdefkey{latin}{timesep}{\renewcommand*{\DTMlatintimesep}{#1}}
306 % \end{macrocode}
307 %
308 % TODO: provide a boolean key to switch between full and abbreviated
309 % formats if appropriate. (I don't know how the date should be
310 % abbreviated.)
311 %
312 % Define a boolean key that determines if the time zone mappings
313 % should be used.
314 % \begin{macrocode}
315 \DTMdefboolkey{latin}{mapzone}[true]{}
316 % \end{macrocode}
317 % The default is to use mappings.
318 % \begin{macrocode}
319 \DTMsetbool{latin}{mapzone}{true}
320 % \end{macrocode}
321 %
322 % Define a boolean key that determines if the day of month should be
323 % displayed.
324 % \begin{macrocode}
325 \DTMdefboolkey{latin}{showdayofmonth}[true]{}
326 % \end{macrocode}
327 % The default is to show the day of month.
328 % \begin{macrocode}
329 \DTMsetbool{latin}{showdayofmonth}{true}
330 % \end{macrocode}
331 %
332 % Define a boolean key that determines if the year should be
333 % displayed.
334 % \begin{macrocode}
335 \DTMdefboolkey{latin}{showyear}[true]{}
336 % \end{macrocode}
337 % The default is to show the year.
338 % \begin{macrocode}
339 \DTMsetbool{latin}{showyear}{true}
340 % \end{macrocode}
341 %
342 % Define the "latin" style. (TODO: implement day of week?)
343 % \begin{macrocode}
344 \DTMnewstyle
345 {latin}% label
346 {% date style
347 \renewcommand*\DTMdisplaydate[4]{%
348 \DTMifbool{latin}{showdayofmonth}
349 {\DTMlatinordinal{##3}\DTMlatindaymonthsep}%
350 {}%
351 \DTMlatinmonthname{##2}%
352 \DTMifbool{latin}{showyear}%
353 {%
354 \DTMlatinmonthyearsep
355 \DTMlatinyear{##1}%
356 }%
357 {}%
358 }%
359 \renewcommand*\DTMDisplaydate{\DTMdisplaydate}%
360 }%
361 {% time style (use default)
362 \DTMsettimestyle{default}%
363 }%
364 {% zone style
365 \DTMresetzones
366 \DTMlatinzonemaps
367 \renewcommand*{\DTMdisplayzone}[2]{%
368 \DTMifbool{latin}{mapzone}%
369 {\DTMusezonemapordefault{##1}{##2}}%
370 {%
371 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
372 \ifDTMshowzoneminutes\DTMlatintimesep\DTMtwodigits{##2}\fi
373 }%
374 }%
375 }%
376 {% full style
377 \renewcommand*{\DTMdisplay}[9]{%
378 \ifDTMshowdate
379 \DTMdisplaydate{##1}{##2}{##3}{##4}%
380 \DTMlatindatetimesep
381 \fi
382 \DTMdisplaytime{##5}{##6}{##7}%
383 \ifDTMshowzone
384 \DTMlatintimezonesep
385 \DTMdisplayzone{##8}{##9}%
386 \fi
387 }%
388 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
389 }%
390 % \end{macrocode}
391 %
392 % Define numeric style.
393 % \begin{macrocode}
394 \DTMnewstyle
395 {latin-numeric}% label
396 {% date style
397 \renewcommand*\DTMdisplaydate[4]{%
398 \DTMifbool{latin}{showdayofmonth}%
399 {%
400 \number##3 % space intended
401 \DTMlatindatesep
402 }%
403 {}%
404 \number##2 % space intended
405 \DTMifbool{latin}{showyear}%
406 {%
407 \DTMlatindatesep
408 \number##1 % space intended
409 }%
410 {}%
411 }%
412 \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}%
413 }%
414 {% time style
415 \renewcommand*\DTMdisplaytime[3]{%
416 \number##1
417 \DTMlatintimesep\DTMtwodigits{##2}%
418 \ifDTMshowseconds\DTMlatintimesep\DTMtwodigits{##3}\fi
419 }%
420 }%
421 {% zone style
422 \DTMresetzones
423 \DTMlatinzonemaps
424 \renewcommand*{\DTMdisplayzone}[2]{%
425 \DTMifbool{latin}{mapzone}%
426 {\DTMusezonemapordefault{##1}{##2}}%
427 {%
428 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
429 \ifDTMshowzoneminutes\DTMlatintimesep\DTMtwodigits{##2}\fi
430 }%
431 }%
432 }%
433 {% full style
434 \renewcommand*{\DTMdisplay}[9]{%
435 \ifDTMshowdate
436 \DTMdisplaydate{##1}{##2}{##3}{##4}%
437 \DTMlatindatetimesep
438 \fi
439 \DTMdisplaytime{##5}{##6}{##7}%
440 \ifDTMshowzone
441 \DTMlatintimezonesep
442 \DTMdisplayzone{##8}{##9}%
443 \fi
444 }%
445 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
446 }
447 % \end{macrocode}
448 %
449 %\begin{macro}{\DTMlatinzonemaps}
450 % The time zone mappings are set through this command, which can be
451 % redefined if extra mappings are required or mappings need to be
452 % removed. This currently has no mappings.
453 % \begin{macrocode}
454 \newcommand*{\DTMlatinzonemaps}{%
455 }
456 % \end{macrocode}
457 %\end{macro}
458
459 % Switch style according to the \opt{useregional} setting.
460 % \begin{macrocode}
461 \DTMifcaseregional
462 {}% do nothing
463 {\DTMsetstyle{latin}}
464 {\DTMsetstyle{latin-numeric}}
465 % \end{macrocode}
466 %
467 % Redefine \cs{datelatin} (or \cs{date}\meta{dialect}) to prevent
468 % \sty{babel} from resetting \cs{today}. (For this to work,
469 % \sty{babel} must already have been loaded if it's required.)
470 %\changes{1.1}{2018-05-18}{removed spurious space}
471 % \begin{macrocode}
472 \ifcsundef{date\CurrentTrackedDialect}
473 {%
474 \ifundef\datelatin
475 {% do nothing
476 }%
477 {%
478 \def\datelatin{%
479 \DTMifcaseregional
480 {}% do nothing
481 {\DTMsetstyle{latin}}%
482 {\DTMsetstyle{latin-numeric}}%
483 }%
484 }%
485 }%
486 {%
487 \csdef{date\CurrentTrackedDialect}{%
488 \DTMifcaseregional
489 {}% do nothing
490 {\DTMsetstyle{latin}}%
491 {\DTMsetstyle{latin-numeric}}%
492 }%
493 }%
494 % \end{macrocode}
495 %\iffalse
496 % \begin{macrocode}
497 %</datetime2-latin.ldf>
498 % \end{macrocode}
499 %\fi
500 %\Finale
501 \endinput