Debian Codegraph @

texmf-dist/source/latex/datetime2-catalan/datetime2-catalan.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 Catalan Module}]{hyperref}
38
39
40 \CheckSum{258}
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-catalan.dtx}
56 \end{document}
57 %</driver>
58 %\fi
59 %
60 %\MakeShortVerb{"}
61 %
62 %\title{Catalan Module for datetime2 Package}
63 %\author{Nicola L. C. Talbot (inactive)}
64 %\date{2018-03-19 (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 Catalan 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-catalan}'s \cs{today}.
85 %
86 %I don't know if these settings are correct as I can't speak Catalan.
87 %In particular, I don't know if the "catalan" time style is
88 %correct. Currently this just uses the "default" time style. Please
89 %be aware that this may change. Whoever takes over maintanance
90 %of this module may can change it as appropriate.
91 %
92 %The new maintainer should add the line:
93 %\begin{verbatim}
94 % The Current Maintainer of this work is Name.
95 %\end{verbatim}
96 %to the preamble part in \texttt{datetime2-catalan.ins} where Name
97 %is the name of the maintainer(s) and replace
98 %the `inactive' status to `maintained'.
99 %
100 %Currently there is only a regionless style.
101 %
102 %\StopEventually{%
103 %\clearpage
104 %\phantomsection
105 %\addcontentsline{toc}{section}{Change History}%
106 %\PrintChanges
107 %\addcontentsline{toc}{section}{\indexname}%
108 %\PrintIndex}
109 %\section{The Code}
110 %\iffalse
111 % \begin{macrocode}
112 %<*datetime2-catalan-utf8.ldf>
113 % \end{macrocode}
114 %\fi
115 %\subsection{UTF-8}
116 %This file contains the settings that use UTF-8 characters. This
117 %file is loaded if XeLaTeX or LuaLaTeX are used. Please make sure
118 %your text editor is set to UTF-8 if you want to view this code.
119 %\changes{1.0}{2015-03-29}{Initial release}
120 % Identify module
121 % \begin{macrocode}
122 \ProvidesDateTimeModule{catalan-utf8}[2018/03/19 v1.1]
123 % \end{macrocode}
124 %\begin{macro}{\DTMcatalanordinal}
125 % \begin{macrocode}
126 \newcommand*{\DTMcatalanordinal}[1]{%
127 \number#1
128 }
129 % \end{macrocode}
130 %\end{macro}
131 %
132 %\begin{macro}{\DTMcatalanmonthname}
133 % Catalan month names.
134 % \begin{macrocode}
135 \newcommand*{\DTMcatalanmonthname}[1]{%
136 \ifcase#1
137 \or
138 de gener%
139 \or
140 de febrer%
141 \or
142 de març%
143 \or
144 d'abril%
145 \or
146 de maig%
147 \or
148 de juny%
149 \or
150 de juliol%
151 \or
152 d'agost%
153 \or
154 de setembre%
155 \or
156 d'octubre%
157 \or
158 de novembre%
159 \or
160 de desembre%
161 \fi
162 }
163 % \end{macrocode}
164 %\end{macro}
165 %
166 %\begin{macro}{\DTMcatalanMonthname}
167 % As above but start with a capital.
168 % \begin{macrocode}
169 \newcommand*{\DTMcatalanMonthname}[1]{%
170 \ifcase#1
171 \or
172 De gener%
173 \or
174 De febrer%
175 \or
176 De març%
177 \or
178 D'abril%
179 \or
180 De maig%
181 \or
182 De juny%
183 \or
184 De juliol%
185 \or
186 D'agost%
187 \or
188 De setembre%
189 \or
190 D'octubre%
191 \or
192 De novembre%
193 \or
194 De desembre%
195 \fi
196 }
197 % \end{macrocode}
198 %\end{macro}
199 %
200 %If abbreviated dates are supported, short month names should be
201 %likewise provided.
202 %
203 %\iffalse
204 % \begin{macrocode}
205 %</datetime2-catalan-utf8.ldf>
206 % \end{macrocode}
207 %\fi
208 %\iffalse
209 % \begin{macrocode}
210 %<*datetime2-catalan-ascii.ldf>
211 % \end{macrocode}
212 %\fi
213 %\subsection{ASCII}
214 %This file contains the settings that use \LaTeX\ commands for
215 %non-ASCII characters. This should be input if neither XeLaTeX nor
216 %LuaLaTeX are used. Even if the user has loaded \sty{inputenc} with
217 %"utf8", this file should still be used not the
218 %\texttt{datetime2-catalan-utf8.ldf} file as the non-ASCII
219 %characters are made active in that situation and would need
220 %protecting against expansion.
221 %\changes{1.0}{2015-03-29}{Initial release}
222 % Identify module
223 % \begin{macrocode}
224 \ProvidesDateTimeModule{catalan-ascii}[2018/03/19 v1.1]
225 % \end{macrocode}
226 %
227 %If abbreviated dates are supported, short month names should be
228 %likewise provided.
229 %\begin{macro}{\DTMcatalanordinal}
230 % \begin{macrocode}
231 \newcommand*{\DTMcatalanordinal}[1]{%
232 \number#1
233 }
234 % \end{macrocode}
235 %\end{macro}
236 %
237 %\begin{macro}{\DTMcatalanmonthname}
238 % Catalan month names.
239 % \begin{macrocode}
240 \newcommand*{\DTMcatalanmonthname}[1]{%
241 \ifcase#1
242 \or
243 de gener%
244 \or
245 de febrer%
246 \or
247 de mar\protect\c{c}%
248 \or
249 d'abril%
250 \or
251 de maig%
252 \or
253 de juny%
254 \or
255 de juliol%
256 \or
257 d'agost%
258 \or
259 de setembre%
260 \or
261 d'octubre%
262 \or
263 de novembre%
264 \or
265 de desembre%
266 \fi
267 }
268 % \end{macrocode}
269 %\end{macro}
270 %
271 %\begin{macro}{\DTMcatalanMonthname}
272 % As above but start with a capital.
273 % \begin{macrocode}
274 \newcommand*{\DTMcatalanMonthname}[1]{%
275 \ifcase#1
276 \or
277 De gener%
278 \or
279 De febrer%
280 \or
281 De mar\protect\c{c}%
282 \or
283 D'abril%
284 \or
285 De maig%
286 \or
287 De juny%
288 \or
289 De juliol%
290 \or
291 D'agost%
292 \or
293 De setembre%
294 \or
295 D'octubre%
296 \or
297 De novembre%
298 \or
299 De desembre%
300 \fi
301 }
302 % \end{macrocode}
303 %\end{macro}
304 %
305 %
306 %\iffalse
307 % \begin{macrocode}
308 %</datetime2-catalan-ascii.ldf>
309 % \end{macrocode}
310 %\fi
311 %
312 %\subsection{Main Catalan Module (\texttt{datetime2-catalan.ldf})}
313 %\changes{1.0}{2015-03-29}{Initial release}
314 %
315 %\iffalse
316 % \begin{macrocode}
317 %<*datetime2-catalan.ldf>
318 % \end{macrocode}
319 %\fi
320 %
321 % Identify Module
322 % \begin{macrocode}
323 \ProvidesDateTimeModule{catalan}[2018/03/19 v1.1]
324 % \end{macrocode}
325 % Need to find out if XeTeX or LuaTeX are being used.
326 % \begin{macrocode}
327 \RequirePackage{ifxetex,ifluatex}
328 % \end{macrocode}
329 % XeTeX and LuaTeX natively support UTF-8, so load
330 % \texttt{catalan-utf8} if either of those engines are used
331 % otherwise load \texttt{catalan-ascii}.
332 % \begin{macrocode}
333 \ifxetex
334 \RequireDateTimeModule{catalan-utf8}
335 \else
336 \ifluatex
337 \RequireDateTimeModule{catalan-utf8}
338 \else
339 \RequireDateTimeModule{catalan-ascii}
340 \fi
341 \fi
342 % \end{macrocode}
343 %
344 % Define the \texttt{catalan} style.
345 % The time style is the same as the "default" style
346 % provided by \sty{datetime2}. This may need correcting. For
347 % example, if a 12 hour style similar to the "englishampm" (from the
348 % "english-base" module) is required.
349 %
350 % Allow the user a way of configuring the "catalan" and
351 % "catalan-numeric" styles. This doesn't use the package wide
352 % separators such as
353 % \cs{dtm@datetimesep} in case other date formats are also required.
354 %\begin{macro}{\DTMcatalandaymonthsep}
355 % The separator between the day and month for the text format.
356 % \begin{macrocode}
357 \newcommand*{\DTMcatalandaymonthsep}{\space}
358 % \end{macrocode}
359 %\end{macro}
360 %
361 %\begin{macro}{\DTMcatalanmonthyearsep}
362 % The separator between the month and year for the text format.
363 % \begin{macrocode}
364 \newcommand*{\DTMcatalanmonthyearsep}{%
365 \space de\DTMtexorpdfstring{\protect~}{\space}}
366 % \end{macrocode}
367 %\end{macro}
368 %
369 %\begin{macro}{\DTMcatalandatetimesep}
370 % The separator between the date and time blocks in the full format
371 % (either text or numeric).
372 % \begin{macrocode}
373 \newcommand*{\DTMcatalandatetimesep}{\space}
374 % \end{macrocode}
375 %\end{macro}
376 %
377 %\begin{macro}{\DTMcatalantimezonesep}
378 % The separator between the time and zone blocks in the full format
379 % (either text or numeric).
380 % \begin{macrocode}
381 \newcommand*{\DTMcatalantimezonesep}{\space}
382 % \end{macrocode}
383 %\end{macro}
384 %
385 %\begin{macro}{\DTMcatalandatesep}
386 % The separator for the numeric date format.
387 % \begin{macrocode}
388 \newcommand*{\DTMcatalandatesep}{/}
389 % \end{macrocode}
390 %\end{macro}
391 %
392 %\begin{macro}{\DTMcatalantimesep}
393 % The separator for the numeric time format.
394 % \begin{macrocode}
395 \newcommand*{\DTMcatalantimesep}{:}
396 % \end{macrocode}
397 %\end{macro}
398 %
399 %Provide keys that can be used in \cs{DTMlangsetup} to set these
400 %separators.
401 % \begin{macrocode}
402 \DTMdefkey{catalan}{daymonthsep}{\renewcommand*{\DTMcatalandaymonthsep}{#1}}
403 \DTMdefkey{catalan}{monthyearsep}{\renewcommand*{\DTMcatalanmonthyearsep}{#1}}
404 \DTMdefkey{catalan}{datetimesep}{\renewcommand*{\DTMcatalandatetimesep}{#1}}
405 \DTMdefkey{catalan}{timezonesep}{\renewcommand*{\DTMcatalantimezonesep}{#1}}
406 \DTMdefkey{catalan}{datesep}{\renewcommand*{\DTMcatalandatesep}{#1}}
407 \DTMdefkey{catalan}{timesep}{\renewcommand*{\DTMcatalantimesep}{#1}}
408 % \end{macrocode}
409 %
410 % TODO: provide a boolean key to switch between full and abbreviated
411 % formats if appropriate. (I don't know how the date should be
412 % abbreviated.)
413 %
414 % Define a boolean key that determines if the time zone mappings
415 % should be used.
416 % \begin{macrocode}
417 \DTMdefboolkey{catalan}{mapzone}[true]{}
418 % \end{macrocode}
419 % The default is to use mappings.
420 % \begin{macrocode}
421 \DTMsetbool{catalan}{mapzone}{true}
422 % \end{macrocode}
423 %
424 % Define a boolean key that determines if the day of month should be
425 % displayed.
426 % \begin{macrocode}
427 \DTMdefboolkey{catalan}{showdayofmonth}[true]{}
428 % \end{macrocode}
429 % The default is to show the day of month.
430 % \begin{macrocode}
431 \DTMsetbool{catalan}{showdayofmonth}{true}
432 % \end{macrocode}
433 %
434 % Define a boolean key that determines if the year should be
435 % displayed.
436 % \begin{macrocode}
437 \DTMdefboolkey{catalan}{showyear}[true]{}
438 % \end{macrocode}
439 % The default is to show the year.
440 % \begin{macrocode}
441 \DTMsetbool{catalan}{showyear}{true}
442 % \end{macrocode}
443 %
444 % Define the "catalan" style. (TODO: implement day of week?)
445 % \begin{macrocode}
446 \DTMnewstyle
447 {catalan}% label
448 {% date style
449 \renewcommand*\DTMdisplaydate[4]{%
450 \DTMifbool{catalan}{showdayofmonth}
451 {\DTMcatalanordinal{##3}\DTMcatalandaymonthsep}%
452 {}%
453 \DTMcatalanmonthname{##2}%
454 \DTMifbool{catalan}{showyear}%
455 {%
456 \DTMcatalanmonthyearsep
457 \number##1 % space intended
458 }%
459 {}%
460 }%
461 \renewcommand*\DTMDisplaydate[4]{%
462 \DTMifbool{catalan}{showdayofmonth}
463 {%
464 \DTMcatalanordinal{##3}\DTMcatalandaymonthsep
465 \DTMcatalanmonthname{##2}%
466 }%
467 {\DTMcatalanMonthname{##2}}%
468 \DTMifbool{catalan}{showyear}%
469 {%
470 \DTMcatalanmonthyearsep
471 \number##1 % space intended
472 }%
473 {}%
474 }%
475 }%
476 {% time style (use default)
477 \DTMsettimestyle{default}%
478 }%
479 {% zone style
480 \DTMresetzones
481 \DTMcatalanzonemaps
482 \renewcommand*{\DTMdisplayzone}[2]{%
483 \DTMifbool{catalan}{mapzone}%
484 {\DTMusezonemapordefault{##1}{##2}}%
485 {%
486 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
487 \ifDTMshowzoneminutes\DTMcatalantimesep\DTMtwodigits{##2}\fi
488 }%
489 }%
490 }%
491 {% full style
492 \renewcommand*{\DTMdisplay}[9]{%
493 \ifDTMshowdate
494 \DTMdisplaydate{##1}{##2}{##3}{##4}%
495 \DTMcatalandatetimesep
496 \fi
497 \DTMdisplaytime{##5}{##6}{##7}%
498 \ifDTMshowzone
499 \DTMcatalantimezonesep
500 \DTMdisplayzone{##8}{##9}%
501 \fi
502 }%
503 \renewcommand*{\DTMDisplay}[9]{%
504 \ifDTMshowdate
505 \DTMDisplaydate{##1}{##2}{##3}{##4}%
506 \DTMcatalandatetimesep
507 \fi
508 \DTMdisplaytime{##5}{##6}{##7}%
509 \ifDTMshowzone
510 \DTMcatalantimezonesep
511 \DTMdisplayzone{##8}{##9}%
512 \fi
513 }%
514 }%
515 % \end{macrocode}
516 %
517 % Define numeric style.
518 % \begin{macrocode}
519 \DTMnewstyle
520 {catalan-numeric}% label
521 {% date style
522 \renewcommand*\DTMdisplaydate[4]{%
523 \DTMifbool{catalan}{showdayofmonth}%
524 {%
525 \number##3 % space intended
526 \DTMcatalandatesep
527 }%
528 {}%
529 \number##2 % space intended
530 \DTMifbool{catalan}{showyear}%
531 {%
532 \DTMcatalandatesep
533 \number##1 % space intended
534 }%
535 {}%
536 }%
537 \renewcommand*{\DTMDisplaydate}[4]{\DTMdisplaydate{##1}{##2}{##3}{##4}}%
538 }%
539 {% time style
540 \renewcommand*\DTMdisplaytime[3]{%
541 \number##1
542 \DTMcatalantimesep\DTMtwodigits{##2}%
543 \ifDTMshowseconds\DTMcatalantimesep\DTMtwodigits{##3}\fi
544 }%
545 }%
546 {% zone style
547 \DTMresetzones
548 \DTMcatalanzonemaps
549 \renewcommand*{\DTMdisplayzone}[2]{%
550 \DTMifbool{catalan}{mapzone}%
551 {\DTMusezonemapordefault{##1}{##2}}%
552 {%
553 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
554 \ifDTMshowzoneminutes\DTMcatalantimesep\DTMtwodigits{##2}\fi
555 }%
556 }%
557 }%
558 {% full style
559 \renewcommand*{\DTMdisplay}[9]{%
560 \ifDTMshowdate
561 \DTMdisplaydate{##1}{##2}{##3}{##4}%
562 \DTMcatalandatetimesep
563 \fi
564 \DTMdisplaytime{##5}{##6}{##7}%
565 \ifDTMshowzone
566 \DTMcatalantimezonesep
567 \DTMdisplayzone{##8}{##9}%
568 \fi
569 }%
570 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
571 }
572 % \end{macrocode}
573 %
574 %\begin{macro}{\DTMcatalanzonemaps}
575 % The time zone mappings are set through this command, which can be
576 % redefined if extra mappings are required or mappings need to be
577 % removed.
578 % \begin{macrocode}
579 \newcommand*{\DTMcatalanzonemaps}{%
580 \DTMdefzonemap{01}{00}{CET}%
581 \DTMdefzonemap{02}{00}{CEST}%
582 }
583 % \end{macrocode}
584 %\end{macro}
585
586 % Switch style according to the \opt{useregional} setting.
587 % \begin{macrocode}
588 \DTMifcaseregional
589 {}% do nothing
590 {\DTMsetstyle{catalan}}
591 {\DTMsetstyle{catalan-numeric}}
592 % \end{macrocode}
593 %
594 % Redefine \cs{datecatalan} (or \cs{date}\meta{dialect}) to prevent
595 % \sty{babel} from resetting \cs{today}. (For this to work,
596 % \sty{babel} must already have been loaded if it's required.)
597 %\changes{1.1}{2018-03-19}{removed spurious space}
598 % \begin{macrocode}
599 \ifcsundef{date\CurrentTrackedDialect}
600 {%
601 \ifundef\datecatalan
602 {% do nothing
603 }%
604 {%
605 \def\datecatalan{%
606 \DTMifcaseregional
607 {}% do nothing
608 {\DTMsetstyle{catalan}}%
609 {\DTMsetstyle{catalan-numeric}}%
610 }%
611 }%
612 }%
613 {%
614 \csdef{date\CurrentTrackedDialect}{%
615 \DTMifcaseregional
616 {}% do nothing
617 {\DTMsetstyle{catalan}}%
618 {\DTMsetstyle{catalan-numeric}}%
619 }%
620 }%
621 % \end{macrocode}
622 %\iffalse
623 % \begin{macrocode}
624 %</datetime2-catalan.ldf>
625 % \end{macrocode}
626 %\fi
627 %\Finale
628 \endinput