Debian Codegraph @

texmf-dist/source/latex/datetime2-portuges/datetime2-portuges.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) 2015-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 Portuguese Module}]{hyperref}
38
39
40 \CheckSum{267}
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-portuges.dtx}
56 \end{document}
57 %</driver>
58 %\fi
59 %
60 %\MakeShortVerb{"}
61 %
62 %\title{Portuguese Module for datetime2 Package}
63 %\author{Nicola L. C. Talbot (inactive)}
64 %\date{2018-08-21 (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 maintenance, contact me at
69 %\url{http://www.dickimaw-books.com/contact.html}
70 %
71 %\begin{abstract}
72 %This is the Portuguese 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-portuges}'s \cs{today}.
85 %
86 %I don't know if these settings are correct.
87 %In particular, I don't know if the "portuges" 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-portuges.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 "pt-PT"\slash"pt-PT-numeric",
102 %"pt-BR"\slash"pt-BR-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-portuges-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{portuges-utf8}[2018/08/21 v1.1]
126 % \end{macrocode}
127 %\begin{macro}{\DTMportugesordinal}
128 % \begin{macrocode}
129 \newcommand*{\DTMportugesordinal}[1]{%
130 \number#1
131 }
132 % \end{macrocode}
133 %\end{macro}
134 %
135 %\begin{macro}{\DTMportugesmonthname}
136 % Portuguese month names.
137 % \begin{macrocode}
138 \newcommand*{\DTMportugesmonthname}[1]{%
139 \ifcase#1
140 \or
141 Janeiro%
142 \or
143 Fevereiro%
144 \or
145 Março%
146 \or
147 Abril%
148 \or
149 Maio%
150 \or
151 Junho%
152 \or
153 Julho%
154 \or
155 Agosto%
156 \or
157 Setembro%
158 \or
159 Outubro%
160 \or
161 Novembro%
162 \or
163 Dezembro%
164 \fi
165 }
166 % \end{macrocode}
167 %\end{macro}
168 %
169 %If abbreviated dates are supported, short month names should be
170 %likewise provided.
171 %
172 %\begin{macro}{\DTMportugesweekdayname}
173 %These are provided here but not currently used in the date format.
174 % \begin{macrocode}
175 \newcommand*{\DTMportugesweekdayname}[1]{%
176 \ifcase#1
177 domingo%
178 \or
179 segunda-feira%
180 \or
181 terça-feira%
182 \or
183 quarta-feira%
184 \or
185 quinta-feira%
186 \or
187 sexta-feira%
188 \or
189 sabado%
190 \fi
191 }
192 % \end{macrocode}
193 %\end{macro}
194 %
195 %\begin{macro}{\DTMportugesWeekdayname}
196 %As above but start with a capital.
197 % \begin{macrocode}
198 \newcommand*{\DTMportugesWeekdayname}[1]{%
199 \ifcase#1
200 Domingo%
201 \or
202 Segunda-feira%
203 \or
204 Terça-feira%
205 \or
206 Quarta-feira%
207 \or
208 Quinta-feira%
209 \or
210 Sexta-feira%
211 \or
212 Sabado%
213 \fi
214 }
215 % \end{macrocode}
216 %\end{macro}
217 %
218 %\iffalse
219 % \begin{macrocode}
220 %</datetime2-portuges-utf8.ldf>
221 % \end{macrocode}
222 %\fi
223 %\iffalse
224 % \begin{macrocode}
225 %<*datetime2-portuges-ascii.ldf>
226 % \end{macrocode}
227 %\fi
228 %\subsection{ASCII}
229 %This file contains the settings that use \LaTeX\ commands for
230 %non-ASCII characters. This should be input if neither XeLaTeX nor
231 %LuaLaTeX are used. Even if the user has loaded \sty{inputenc} with
232 %"utf8", this file should still be used not the
233 %\texttt{datetime2-portuges-utf8.ldf} file as the non-ASCII
234 %characters are made active in that situation and would need
235 %protecting against expansion.
236 %\changes{1.0}{2015-03-28}{Initial release}
237 % Identify module
238 % \begin{macrocode}
239 \ProvidesDateTimeModule{portuges-ascii}[2018/08/21 v1.1]
240 % \end{macrocode}
241 %
242 %If abbreviated dates are supported, short month names should be
243 %likewise provided.
244 %\begin{macro}{\DTMportugesordinal}
245 % \begin{macrocode}
246 \newcommand*{\DTMportugesordinal}[1]{%
247 \number#1
248 }
249 % \end{macrocode}
250 %\end{macro}
251 %
252 %\begin{macro}{\DTMportugesmonthname}
253 % Portuguese month names.
254 % \begin{macrocode}
255 \newcommand*{\DTMportugesmonthname}[1]{%
256 \ifcase#1
257 \or
258 Janeiro%
259 \or
260 Fevereiro%
261 \or
262 Mar\protect\c{c}o%
263 \or
264 Abril%
265 \or
266 Maio%
267 \or
268 Junho%
269 \or
270 Julho%
271 \or
272 Agosto%
273 \or
274 Setembro%
275 \or
276 Outubro%
277 \or
278 Novembro%
279 \or
280 Dezembro%
281 \fi
282 }
283 % \end{macrocode}
284 %\end{macro}
285 %
286 %\begin{macro}{\DTMportugesweekdayname}
287 %These are provided here but not currently used in the date format.
288 % \begin{macrocode}
289 \newcommand*{\DTMportugesweekdayname}[1]{%
290 \ifcase#1
291 domingo%
292 \or
293 segunda-feira%
294 \or
295 ter\protect\c{c}a-feira%
296 \or
297 quarta-feira%
298 \or
299 quinta-feira%
300 \or
301 sexta-feira%
302 \or
303 sabado%
304 \fi
305 }
306 % \end{macrocode}
307 %\end{macro}
308 %
309 %\begin{macro}{\DTMportugesWeekdayname}
310 %As above but start with a capital.
311 % \begin{macrocode}
312 \newcommand*{\DTMportugesWeekdayname}[1]{%
313 \ifcase#1
314 Domingo%
315 \or
316 Segunda-feira%
317 \or
318 Ter\protect\c{c}a-feira%
319 \or
320 Quarta-feira%
321 \or
322 Quinta-feira%
323 \or
324 Sexta-feira%
325 \or
326 Sabado%
327 \fi
328 }
329 % \end{macrocode}
330 %\end{macro}
331 %
332 %
333 %\iffalse
334 % \begin{macrocode}
335 %</datetime2-portuges-ascii.ldf>
336 % \end{macrocode}
337 %\fi
338 %
339 %\subsection{Main Portuguese Module (\texttt{datetime2-portuges.ldf})}
340 %\changes{1.0}{2015-03-28}{Initial release}
341 %
342 %\iffalse
343 % \begin{macrocode}
344 %<*datetime2-portuges.ldf>
345 % \end{macrocode}
346 %\fi
347 %
348 % Identify Module
349 % \begin{macrocode}
350 \ProvidesDateTimeModule{portuges}[2018/08/21 v1.1]
351 % \end{macrocode}
352 % Need to find out if XeTeX or LuaTeX are being used.
353 % \begin{macrocode}
354 \RequirePackage{ifxetex,ifluatex}
355 % \end{macrocode}
356 % XeTeX and LuaTeX natively support UTF-8, so load
357 % \texttt{portuges-utf8} if either of those engines are used
358 % otherwise load \texttt{portuges-ascii}.
359 % \begin{macrocode}
360 \ifxetex
361 \RequireDateTimeModule{portuges-utf8}
362 \else
363 \ifluatex
364 \RequireDateTimeModule{portuges-utf8}
365 \else
366 \RequireDateTimeModule{portuges-ascii}
367 \fi
368 \fi
369 % \end{macrocode}
370 %
371 % Define the \texttt{portuges} style.
372 % The time style is the same as the "default" style
373 % provided by \sty{datetime2}. This may need correcting.
374 %
375 % Allow the user a way of configuring the "portuges" and
376 % "portuges-numeric" styles. This doesn't use the package wide
377 % separators such as
378 % \cs{dtm@datetimesep} in case other date formats are also required.
379 %\begin{macro}{\DTMportugesdaymonthsep}
380 % The separator between the day and month for the text format.
381 % \begin{macrocode}
382 \newcommand*{\DTMportugesdaymonthsep}{\space de\space}
383 % \end{macrocode}
384 %\end{macro}
385 %
386 %\begin{macro}{\DTMportugesmonthyearsep}
387 % The separator between the month and year for the text format.
388 % \begin{macrocode}
389 \newcommand*{\DTMportugesmonthyearsep}{\space de\space}
390 % \end{macrocode}
391 %\end{macro}
392 %
393 %\begin{macro}{\DTMportugesdatetimesep}
394 % The separator between the date and time blocks in the full format
395 % (either text or numeric).
396 % \begin{macrocode}
397 \newcommand*{\DTMportugesdatetimesep}{\space}
398 % \end{macrocode}
399 %\end{macro}
400 %
401 %\begin{macro}{\DTMportugestimezonesep}
402 % The separator between the time and zone blocks in the full format
403 % (either text or numeric).
404 % \begin{macrocode}
405 \newcommand*{\DTMportugestimezonesep}{\space}
406 % \end{macrocode}
407 %\end{macro}
408 %
409 %\begin{macro}{\DTMportugesdatesep}
410 % The separator for the numeric date format.
411 % \begin{macrocode}
412 \newcommand*{\DTMportugesdatesep}{/}
413 % \end{macrocode}
414 %\end{macro}
415 %
416 %\begin{macro}{\DTMportugestimesep}
417 % The separator for the numeric time format.
418 % \begin{macrocode}
419 \newcommand*{\DTMportugestimesep}{:}
420 % \end{macrocode}
421 %\end{macro}
422 %
423 %Provide keys that can be used in \cs{DTMlangsetup} to set these
424 %separators.
425 % \begin{macrocode}
426 \DTMdefkey{portuges}{daymonthsep}{\renewcommand*{\DTMportugesdaymonthsep}{#1}}
427 \DTMdefkey{portuges}{monthyearsep}{\renewcommand*{\DTMportugesmonthyearsep}{#1}}
428 \DTMdefkey{portuges}{datetimesep}{\renewcommand*{\DTMportugesdatetimesep}{#1}}
429 \DTMdefkey{portuges}{timezonesep}{\renewcommand*{\DTMportugestimezonesep}{#1}}
430 \DTMdefkey{portuges}{datesep}{\renewcommand*{\DTMportugesdatesep}{#1}}
431 \DTMdefkey{portuges}{timesep}{\renewcommand*{\DTMportugestimesep}{#1}}
432 % \end{macrocode}
433 %
434 % TODO: provide a boolean key to switch between full and abbreviated
435 % formats if appropriate. (I don't know how the date should be
436 % abbreviated.)
437 %
438 % Define a boolean key that determines if the time zone mappings
439 % should be used.
440 % \begin{macrocode}
441 \DTMdefboolkey{portuges}{mapzone}[true]{}
442 % \end{macrocode}
443 % The default is to use mappings.
444 % \begin{macrocode}
445 \DTMsetbool{portuges}{mapzone}{true}
446 % \end{macrocode}
447 %
448 % Define a boolean key that determines if the day of month should be
449 % displayed.
450 % \begin{macrocode}
451 \DTMdefboolkey{portuges}{showdayofmonth}[true]{}
452 % \end{macrocode}
453 % The default is to show the day of month.
454 % \begin{macrocode}
455 \DTMsetbool{portuges}{showdayofmonth}{true}
456 % \end{macrocode}
457 %
458 % Define a boolean key that determines if the year should be
459 % displayed.
460 % \begin{macrocode}
461 \DTMdefboolkey{portuges}{showyear}[true]{}
462 % \end{macrocode}
463 % The default is to show the year.
464 % \begin{macrocode}
465 \DTMsetbool{portuges}{showyear}{true}
466 % \end{macrocode}
467 %
468 % Define the "portuges" style. (TODO: implement day of week?)
469 % \begin{macrocode}
470 \DTMnewstyle
471 {portuges}% label
472 {% date style
473 \renewcommand*\DTMdisplaydate[4]{%
474 \DTMifbool{portuges}{showdayofmonth}
475 {\DTMportugesordinal{##3}\DTMportugesdaymonthsep}%
476 {}%
477 \DTMportugesmonthname{##2}%
478 \DTMifbool{portuges}{showyear}%
479 {%
480 \DTMportugesmonthyearsep
481 \number##1 % space intended
482 }%
483 {}%
484 }%
485 \renewcommand*\DTMDisplaydate[4]{%
486 \DTMifbool{portuges}{showdayofmonth}
487 {%
488 \DTMportugesordinal{##3}\DTMportugesdaymonthsep
489 \DTMportugesmonthname{##2}%
490 }%
491 {\DTMportugesmonthname{##2}}%
492 \DTMifbool{portuges}{showyear}%
493 {%
494 \DTMportugesmonthyearsep
495 \number##1 % space intended
496 }%
497 {}%
498 }%
499 }%
500 {% time style (use default)
501 \DTMsettimestyle{default}%
502 }%
503 {% zone style
504 \DTMresetzones
505 \DTMportugeszonemaps
506 \renewcommand*{\DTMdisplayzone}[2]{%
507 \DTMifbool{portuges}{mapzone}%
508 {\DTMusezonemapordefault{##1}{##2}}%
509 {%
510 \ifnum##1<0 \else+\fi\DTMtwodigits{##1}%
511 \ifDTMshowzoneminutes\DTMportugestimesep\DTMtwodigits{##2}\fi
512 }%
513 }%
514 }%
515 {% full style
516 \renewcommand*{\DTMdisplay}[9]{%
517 \ifDTMshowdate
518 \DTMdisplaydate{##1}{##2}{##3}{##4}%
519 \DTMportugesdatetimesep
520 \fi
521 \DTMdisplaytime{##5}{##6}{##7}%
522 \ifDTMshowzone
523 \DTMportugestimezonesep
524 \DTMdisplayzone{##8}{##9}%
525 \fi
526 }%
527 \renewcommand*{\DTMDisplay}[9]{%
528 \ifDTMshowdate
529 \DTMDisplaydate{##1}{##2}{##3}{##4}%
530 \DTMportugesdatetimesep
531 \fi
532 \DTMdisplaytime{##5}{##6}{##7}%
533 \ifDTMshowzone
534 \DTMportugestimezonesep
535 \DTMdisplayzone{##8}{##9}%
536 \fi
537 }%
538 }%
539 % \end{macrocode}
540 %
541 % Define numeric style.
542 % \begin{macrocode}
543 \DTMnewstyle
544 {portuges-numeric}% label
545 {% date style
546 \renewcommand*\DTMdisplaydate[4]{%
547 \DTMifbool{portuges}{showdayofmonth}%
548 {%
549 \number##3 % space intended
550 \DTMportugesdatesep
551 }%
552 {}%
553 \number##2 % space intended
554 \DTMifbool{portuges}{showyear}%
555 {%
556 \DTMportugesdatesep
557 \number##1 % space intended
558 }%
559 {}%
560 }%
561 \renewcommand*{\DTMDisplaydate}[4]{\DTMdisplaydate{##1}{##2}{##3}{##4}}%
562 }%
563 {% time style
564 \renewcommand*\DTMdisplaytime[3]{%
565 \number##1 % space intended
566 \DTMportugestimesep\DTMtwodigits{##2}%
567 \ifDTMshowseconds\DTMportugestimesep\DTMtwodigits{##3}\fi
568 }%
569 }%
570 {% zone style
571 \DTMresetzones
572 \DTMportugeszonemaps
573 \renewcommand*{\DTMdisplayzone}[2]{%
574 \DTMifbool{portuges}{mapzone}%
575 {\DTMusezonemapordefault{##1}{##2}}%
576 {%
577 \ifnum##1<0 \else+\fi\DTMtwodigits{##1}%
578 \ifDTMshowzoneminutes\DTMportugestimesep\DTMtwodigits{##2}\fi
579 }%
580 }%
581 }%
582 {% full style
583 \renewcommand*{\DTMdisplay}[9]{%
584 \ifDTMshowdate
585 \DTMdisplaydate{##1}{##2}{##3}{##4}%
586 \DTMportugesdatetimesep
587 \fi
588 \DTMdisplaytime{##5}{##6}{##7}%
589 \ifDTMshowzone
590 \DTMportugestimezonesep
591 \DTMdisplayzone{##8}{##9}%
592 \fi
593 }%
594 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
595 }
596 % \end{macrocode}
597 %
598 %\begin{macro}{\DTMportugeszonemaps}
599 % The time zone mappings are set through this command, which can be
600 % redefined if extra mappings are required or mappings need to be
601 % removed.
602 % \begin{macrocode}
603 \newcommand*{\DTMportugeszonemaps}{%
604 \DTMdefzonemap{01}{00}{CET}%
605 \DTMdefzonemap{02}{00}{CEST}%
606 }
607 % \end{macrocode}
608 %\end{macro}
609
610 % Switch style according to the \opt{useregional} setting.
611 % \begin{macrocode}
612 \DTMifcaseregional
613 {}% do nothing
614 {\DTMsetstyle{portuges}}
615 {\DTMsetstyle{portuges-numeric}}
616 % \end{macrocode}
617 %
618 % Redefine \cs{dateportuges} (or \cs{date}\meta{dialect}) to prevent
619 % \sty{babel} from resetting \cs{today}. (For this to work,
620 % \sty{babel} must already have been loaded if it's required.)
621 %\changes{1.1}{2018-08-21}{removed spurious space}
622 % \begin{macrocode}
623 \ifcsundef{date\CurrentTrackedDialect}
624 {%
625 \ifundef\dateportuges
626 {% do nothing
627 }%
628 {%
629 \def\dateportuges{%
630 \DTMifcaseregional
631 {}% do nothing
632 {\DTMsetstyle{portuges}}%
633 {\DTMsetstyle{portuges-numeric}}%
634 }%
635 }%
636 }%
637 {%
638 \csdef{date\CurrentTrackedDialect}{%
639 \DTMifcaseregional
640 {}% do nothing
641 {\DTMsetstyle{portuges}}%
642 {\DTMsetstyle{portuges-numeric}}%
643 }%
644 }%
645 % \end{macrocode}
646 %\iffalse
647 % \begin{macrocode}
648 %</datetime2-portuges.ldf>
649 % \end{macrocode}
650 %\fi
651 %\Finale
652 \endinput