Debian Codegraph @

texmf-dist/source/latex/datetime2-spanish/datetime2-spanish.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) 2017 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 Spanish Module}]{hyperref}
38
39
40 \CheckSum{305}
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-spanish.dtx}
56 \end{document}
57 %</driver>
58 %\fi
59 %
60 %\MakeShortVerb{"}
61 %
62 %\title{Spanish Module for datetime2 Package}
63 %\author{Nicola L. C. Talbot (inactive)}
64 %\date{2017-11-13 (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 Spanish 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-spanish}'s \cs{today}.
85 %
86 %I don't know if these settings are correct.
87 %In particular, I don't know if the "spanish" 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-spanish.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. New maintainers may
101 %want to add regional variants such as "es-ES"\slash"es-ES-numeric",
102 %"es-AR"\slash"es-AR-numeric" etc. This style currently doesn't check the
103 %\opt{showdow} setting.
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 %\iffalse
114 % \begin{macrocode}
115 %<*datetime2-spanish-utf8.ldf>
116 % \end{macrocode}
117 %\fi
118 %\subsection{UTF-8}
119 %This file contains the settings that use UTF-8 characters. This
120 %file is loaded if XeLaTeX or LuaLaTeX are used. Please make sure
121 %your text editor is set to UTF-8 if you want to view this code.
122 %\changes{1.0}{2015-03-28}{Initial release}
123 % Identify module
124 % \begin{macrocode}
125 \ProvidesDateTimeModule{spanish-utf8}[2017/11/13 v1.1]
126 % \end{macrocode}
127 %\begin{macro}{\DTMspanishordinal}
128 % \begin{macrocode}
129 \newcommand*{\DTMspanishordinal}[1]{%
130 \number#1
131 }
132 % \end{macrocode}
133 %\end{macro}
134 %
135 %\begin{macro}{\DTMspanishmonthname}
136 % Spanish month names.
137 % \begin{macrocode}
138 \newcommand*{\DTMspanishmonthname}[1]{%
139 \ifcase#1
140 \or
141 enero%
142 \or
143 febrero%
144 \or
145 marzo%
146 \or
147 abril%
148 \or
149 mayo%
150 \or
151 junio%
152 \or
153 julio%
154 \or
155 agosto%
156 \or
157 septiembre%
158 \or
159 octubre%
160 \or
161 noviembre%
162 \or
163 diciembre%
164 \fi
165 }
166 % \end{macrocode}
167 %\end{macro}
168 %
169 %\begin{macro}{\DTMspanishMonthname}
170 % As above but start with a capital.
171 % \begin{macrocode}
172 \newcommand*{\DTMspanishMonthname}[1]{%
173 \ifcase#1
174 \or
175 Enero%
176 \or
177 Febrero%
178 \or
179 Marzo%
180 \or
181 Abril%
182 \or
183 Mayo%
184 \or
185 Junio%
186 \or
187 Julio%
188 \or
189 Agosto%
190 \or
191 Septiembre%
192 \or
193 Octubre%
194 \or
195 Noviembre%
196 \or
197 Diciembre%
198 \fi
199 }
200 % \end{macrocode}
201 %\end{macro}
202 %
203 %If abbreviated dates are supported, short month names should be
204 %likewise provided.
205 %
206 %\begin{macro}{\DTMspanishweekdayname}
207 %These are provided here but not currently used in the date format.
208 % \begin{macrocode}
209 \newcommand*{\DTMspanishweekdayname}[1]{%
210 \ifcase#1
211 domingo%
212 \or
213 lunes%
214 \or
215 martes%
216 \or
217 miércoles%
218 \or
219 jueves%
220 \or
221 viernes%
222 \or
223 sábado%
224 \fi
225 }
226 % \end{macrocode}
227 %\end{macro}
228 %
229 %\begin{macro}{\DTMspanishWeekdayname}
230 %As above but start with a capital.
231 % \begin{macrocode}
232 \newcommand*{\DTMspanishWeekdayname}[1]{%
233 \ifcase#1
234 Domingo%
235 \or
236 Lunes%
237 \or
238 Martes%
239 \or
240 Miércoles%
241 \or
242 Jueves%
243 \or
244 Viernes%
245 \or
246 Sábado%
247 \fi
248 }
249 % \end{macrocode}
250 %\end{macro}
251 %
252 %\iffalse
253 % \begin{macrocode}
254 %</datetime2-spanish-utf8.ldf>
255 % \end{macrocode}
256 %\fi
257 %\iffalse
258 % \begin{macrocode}
259 %<*datetime2-spanish-ascii.ldf>
260 % \end{macrocode}
261 %\fi
262 %\subsection{ASCII}
263 %This file contains the settings that use \LaTeX\ commands for
264 %non-ASCII characters. This should be input if neither XeLaTeX nor
265 %LuaLaTeX are used. Even if the user has loaded \sty{inputenc} with
266 %"utf8", this file should still be used not the
267 %\texttt{datetime2-spanish-utf8.ldf} file as the non-ASCII
268 %characters are made active in that situation and would need
269 %protecting against expansion.
270 %\changes{1.0}{2015-03-28}{Initial release}
271 % Identify module
272 % \begin{macrocode}
273 \ProvidesDateTimeModule{spanish-ascii}[2017/11/13 v1.1]
274 % \end{macrocode}
275 %
276 %If abbreviated dates are supported, short month names should be
277 %likewise provided.
278 %\begin{macro}{\DTMspanishordinal}
279 % \begin{macrocode}
280 \newcommand*{\DTMspanishordinal}[1]{%
281 \number#1
282 }
283 % \end{macrocode}
284 %\end{macro}
285 %
286 %\begin{macro}{\DTMspanishmonthname}
287 % Spanish month names.
288 % \begin{macrocode}
289 \newcommand*{\DTMspanishmonthname}[1]{%
290 \ifcase#1
291 \or
292 enero%
293 \or
294 febrero%
295 \or
296 marzo%
297 \or
298 abril%
299 \or
300 mayo%
301 \or
302 junio%
303 \or
304 julio%
305 \or
306 agosto%
307 \or
308 septiembre%
309 \or
310 octubre%
311 \or
312 noviembre%
313 \or
314 diciembre%
315 \fi
316 }
317 % \end{macrocode}
318 %\end{macro}
319 %
320 %\begin{macro}{\DTMspanishMonthname}
321 % As above but start with a capital.
322 % \begin{macrocode}
323 \newcommand*{\DTMspanishMonthname}[1]{%
324 \ifcase#1
325 \or
326 Enero%
327 \or
328 Febrero%
329 \or
330 Marzo%
331 \or
332 Abril%
333 \or
334 Mayo%
335 \or
336 Junio%
337 \or
338 Julio%
339 \or
340 Agosto%
341 \or
342 Septiembre%
343 \or
344 Octubre%
345 \or
346 Noviembre%
347 \or
348 Diciembre%
349 \fi
350 }
351 % \end{macrocode}
352 %\end{macro}
353 %
354 %\begin{macro}{\DTMspanishweekdayname}
355 %These are provided here but not currently used in the date format.
356 % \begin{macrocode}
357 \newcommand*{\DTMspanishweekdayname}[1]{%
358 \ifcase#1
359 domingo%
360 \or
361 lunes%
362 \or
363 martes%
364 \or
365 mi\protect\'ercoles%
366 \or
367 jueves%
368 \or
369 viernes%
370 \or
371 s\protect\'abado%
372 \fi
373 }
374 % \end{macrocode}
375 %\end{macro}
376 %
377 %\begin{macro}{\DTMspanishWeekdayname}
378 %As above but start with a capital.
379 % \begin{macrocode}
380 \newcommand*{\DTMspanishWeekdayname}[1]{%
381 \ifcase#1
382 Domingo%
383 \or
384 Lunes%
385 \or
386 Martes%
387 \or
388 Mi\protect\'ercoles%
389 \or
390 Jueves%
391 \or
392 Viernes%
393 \or
394 S\protect\'abado%
395 \fi
396 }
397 % \end{macrocode}
398 %\end{macro}
399 %
400 %
401 %\iffalse
402 % \begin{macrocode}
403 %</datetime2-spanish-ascii.ldf>
404 % \end{macrocode}
405 %\fi
406 %
407 %\subsection{Main Spanish Module (\texttt{datetime2-spanish.ldf})}
408 %\changes{1.0}{2015-03-28}{Initial release}
409 %
410 %\iffalse
411 % \begin{macrocode}
412 %<*datetime2-spanish.ldf>
413 % \end{macrocode}
414 %\fi
415 %
416 % Identify Module
417 % \begin{macrocode}
418 \ProvidesDateTimeModule{spanish}[2017/11/13 v1.1]
419 % \end{macrocode}
420 % Need to find out if XeTeX or LuaTeX are being used.
421 % \begin{macrocode}
422 \RequirePackage{ifxetex,ifluatex}
423 % \end{macrocode}
424 % XeTeX and LuaTeX natively support UTF-8, so load
425 % \texttt{spanish-utf8} if either of those engines are used
426 % otherwise load \texttt{spanish-ascii}.
427 % \begin{macrocode}
428 \ifxetex
429 \RequireDateTimeModule{spanish-utf8}
430 \else
431 \ifluatex
432 \RequireDateTimeModule{spanish-utf8}
433 \else
434 \RequireDateTimeModule{spanish-ascii}
435 \fi
436 \fi
437 % \end{macrocode}
438 %
439 % Define the \texttt{spanish} style.
440 % The time style is the same as the "default" style
441 % provided by \sty{datetime2}. This may need correcting.
442 %
443 % Allow the user a way of configuring the "spanish" and
444 % "spanish-numeric" styles. This doesn't use the package wide
445 % separators such as
446 % \cs{dtm@datetimesep} in case other date formats are also required.
447 %\begin{macro}{\DTMspanishdaymonthsep}
448 % The separator between the day and month for the text format.
449 % \begin{macrocode}
450 \newcommand*{\DTMspanishdaymonthsep}{%
451 \DTMtexorpdfstring{\protect~}{\space}de\space}
452 % \end{macrocode}
453 %\end{macro}
454 %
455 %\begin{macro}{\DTMspanishmonthyearsep}
456 % The separator between the month and year for the text format.
457 % \begin{macrocode}
458 \newcommand*{\DTMspanishmonthyearsep}{%
459 \space de\DTMtexorpdfstring{\protect~}{\space}}
460 % \end{macrocode}
461 %\end{macro}
462 %
463 %\begin{macro}{\DTMspanishdatetimesep}
464 % The separator between the date and time blocks in the full format
465 % (either text or numeric).
466 % \begin{macrocode}
467 \newcommand*{\DTMspanishdatetimesep}{\space}
468 % \end{macrocode}
469 %\end{macro}
470 %
471 %\begin{macro}{\DTMspanishtimezonesep}
472 % The separator between the time and zone blocks in the full format
473 % (either text or numeric).
474 % \begin{macrocode}
475 \newcommand*{\DTMspanishtimezonesep}{\space}
476 % \end{macrocode}
477 %\end{macro}
478 %
479 %\begin{macro}{\DTMspanishdatesep}
480 % The separator for the numeric date format.
481 % \begin{macrocode}
482 \newcommand*{\DTMspanishdatesep}{/}
483 % \end{macrocode}
484 %\end{macro}
485 %
486 %\begin{macro}{\DTMspanishtimesep}
487 % The separator for the numeric time format.
488 % \begin{macrocode}
489 \newcommand*{\DTMspanishtimesep}{:}
490 % \end{macrocode}
491 %\end{macro}
492 %
493 %Provide keys that can be used in \cs{DTMlangsetup} to set these
494 %separators.
495 % \begin{macrocode}
496 \DTMdefkey{spanish}{daymonthsep}{\renewcommand*{\DTMspanishdaymonthsep}{#1}}
497 \DTMdefkey{spanish}{monthyearsep}{\renewcommand*{\DTMspanishmonthyearsep}{#1}}
498 \DTMdefkey{spanish}{datetimesep}{\renewcommand*{\DTMspanishdatetimesep}{#1}}
499 \DTMdefkey{spanish}{timezonesep}{\renewcommand*{\DTMspanishtimezonesep}{#1}}
500 \DTMdefkey{spanish}{datesep}{\renewcommand*{\DTMspanishdatesep}{#1}}
501 \DTMdefkey{spanish}{timesep}{\renewcommand*{\DTMspanishtimesep}{#1}}
502 % \end{macrocode}
503 %
504 % TODO: provide a boolean key to switch between full and abbreviated
505 % formats if appropriate. (I don't know how the date should be
506 % abbreviated.)
507 %
508 % Define a boolean key that determines if the time zone mappings
509 % should be used.
510 % \begin{macrocode}
511 \DTMdefboolkey{spanish}{mapzone}[true]{}
512 % \end{macrocode}
513 % The default is to use mappings.
514 % \begin{macrocode}
515 \DTMsetbool{spanish}{mapzone}{true}
516 % \end{macrocode}
517 %
518 % Define a boolean key that determines if the day of month should be
519 % displayed.
520 % \begin{macrocode}
521 \DTMdefboolkey{spanish}{showdayofmonth}[true]{}
522 % \end{macrocode}
523 % The default is to show the day of month.
524 % \begin{macrocode}
525 \DTMsetbool{spanish}{showdayofmonth}{true}
526 % \end{macrocode}
527 %
528 % Define a boolean key that determines if the year should be
529 % displayed.
530 % \begin{macrocode}
531 \DTMdefboolkey{spanish}{showyear}[true]{}
532 % \end{macrocode}
533 % The default is to show the year.
534 % \begin{macrocode}
535 \DTMsetbool{spanish}{showyear}{true}
536 % \end{macrocode}
537 %
538 % Define the "spanish" style. (TODO: implement day of week?)
539 % \begin{macrocode}
540 \DTMnewstyle
541 {spanish}% label
542 {% date style
543 \renewcommand*\DTMdisplaydate[4]{%
544 \DTMifbool{spanish}{showdayofmonth}
545 {\DTMspanishordinal{##3}\DTMspanishdaymonthsep}%
546 {}%
547 \DTMspanishmonthname{##2}%
548 \DTMifbool{spanish}{showyear}%
549 {%
550 \DTMspanishmonthyearsep
551 \number##1 % space intended
552 }%
553 {}%
554 }%
555 \renewcommand*\DTMDisplaydate[4]{%
556 \DTMifbool{spanish}{showdayofmonth}
557 {%
558 \DTMspanishordinal{##3}\DTMspanishdaymonthsep
559 \DTMspanishmonthname{##2}%
560 }%
561 {\DTMspanishMonthname{##2}}%
562 \DTMifbool{spanish}{showyear}%
563 {%
564 \DTMspanishmonthyearsep
565 \number##1 % space intended
566 }%
567 {}%
568 }%
569 }%
570 {% time style (use default)
571 \DTMsettimestyle{default}%
572 }%
573 {% zone style
574 \DTMresetzones
575 \DTMspanishzonemaps
576 \renewcommand*{\DTMdisplayzone}[2]{%
577 \DTMifbool{spanish}{mapzone}%
578 {\DTMusezonemapordefault{##1}{##2}}%
579 {%
580 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
581 \ifDTMshowzoneminutes\DTMspanishtimesep\DTMtwodigits{##2}\fi
582 }%
583 }%
584 }%
585 {% full style
586 \renewcommand*{\DTMdisplay}[9]{%
587 \ifDTMshowdate
588 \DTMdisplaydate{##1}{##2}{##3}{##4}%
589 \DTMspanishdatetimesep
590 \fi
591 \DTMdisplaytime{##5}{##6}{##7}%
592 \ifDTMshowzone
593 \DTMspanishtimezonesep
594 \DTMdisplayzone{##8}{##9}%
595 \fi
596 }%
597 \renewcommand*{\DTMDisplay}[9]{%
598 \ifDTMshowdate
599 \DTMDisplaydate{##1}{##2}{##3}{##4}%
600 \DTMspanishdatetimesep
601 \fi
602 \DTMdisplaytime{##5}{##6}{##7}%
603 \ifDTMshowzone
604 \DTMspanishtimezonesep
605 \DTMdisplayzone{##8}{##9}%
606 \fi
607 }%
608 }%
609 % \end{macrocode}
610 %
611 % Define numeric style.
612 % \begin{macrocode}
613 \DTMnewstyle
614 {spanish-numeric}% label
615 {% date style
616 \renewcommand*\DTMdisplaydate[4]{%
617 \DTMifbool{spanish}{showdayofmonth}%
618 {%
619 \number##3 % space intended
620 \DTMspanishdatesep
621 }%
622 {}%
623 \number##2 % space intended
624 \DTMifbool{spanish}{showyear}%
625 {%
626 \DTMspanishdatesep
627 \number##1 % space intended
628 }%
629 {}%
630 }%
631 \renewcommand*{\DTMDisplaydate}[4]{\DTMdisplaydate{##1}{##2}{##3}{##4}}%
632 }%
633 {% time style
634 \renewcommand*\DTMdisplaytime[3]{%
635 \number##1
636 \DTMspanishtimesep\DTMtwodigits{##2}%
637 \ifDTMshowseconds\DTMspanishtimesep\DTMtwodigits{##3}\fi
638 }%
639 }%
640 {% zone style
641 \DTMresetzones
642 \DTMspanishzonemaps
643 \renewcommand*{\DTMdisplayzone}[2]{%
644 \DTMifbool{spanish}{mapzone}%
645 {\DTMusezonemapordefault{##1}{##2}}%
646 {%
647 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
648 \ifDTMshowzoneminutes\DTMspanishtimesep\DTMtwodigits{##2}\fi
649 }%
650 }%
651 }%
652 {% full style
653 \renewcommand*{\DTMdisplay}[9]{%
654 \ifDTMshowdate
655 \DTMdisplaydate{##1}{##2}{##3}{##4}%
656 \DTMspanishdatetimesep
657 \fi
658 \DTMdisplaytime{##5}{##6}{##7}%
659 \ifDTMshowzone
660 \DTMspanishtimezonesep
661 \DTMdisplayzone{##8}{##9}%
662 \fi
663 }%
664 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
665 }
666 % \end{macrocode}
667 %
668 %\begin{macro}{\DTMspanishzonemaps}
669 % The time zone mappings are set through this command, which can be
670 % redefined if extra mappings are required or mappings need to be
671 % removed.
672 % \begin{macrocode}
673 \newcommand*{\DTMspanishzonemaps}{%
674 \DTMdefzonemap{01}{00}{CET}%
675 \DTMdefzonemap{02}{00}{CEST}%
676 }
677 % \end{macrocode}
678 %\end{macro}
679
680 % Switch style according to the \opt{useregional} setting.
681 % \begin{macrocode}
682 \DTMifcaseregional
683 {}% do nothing
684 {\DTMsetstyle{spanish}}
685 {\DTMsetstyle{spanish-numeric}}
686 % \end{macrocode}
687 %
688 % Redefine \cs{datespanish} (or \cs{date}\meta{dialect}) to prevent
689 % \sty{babel} from resetting \cs{today}. (For this to work,
690 % \sty{babel} must already have been loaded if it's required.)
691 %\changes{1.1}{2017-11-13}{removed spurious space caused by eol}
692 % \begin{macrocode}
693 \ifcsundef{date\CurrentTrackedDialect}
694 {%
695 \ifundef\datespanish
696 {% do nothing
697 }%
698 {%
699 \def\datespanish{%
700 \DTMifcaseregional
701 {}% do nothing
702 {\DTMsetstyle{spanish}}%
703 {\DTMsetstyle{spanish-numeric}}%
704 }%
705 }%
706 }%
707 {%
708 \csdef{date\CurrentTrackedDialect}{%
709 \DTMifcaseregional
710 {}% do nothing
711 {\DTMsetstyle{spanish}}%
712 {\DTMsetstyle{spanish-numeric}}%
713 }%
714 }%
715 % \end{macrocode}
716 %\iffalse
717 % \begin{macrocode}
718 %</datetime2-spanish.ldf>
719 % \end{macrocode}
720 %\fi
721 %\Finale
722 \endinput