Debian Codegraph @

texmf-dist/source/latex/datetime2-polish/datetime2-polish.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{fontspec}
32 \usepackage[colorlinks,
33 bookmarks,
34 hyperindex=false,
35 pdfauthor={Nicola L.C. Talbot},
36 pdftitle={datetime2.sty Polish Module}]{hyperref}
37
38 \setmainfont{Liberation Serif}
39 \setmonofont{Liberation Mono}
40
41 \CheckSum{313}
42
43 \renewcommand*{\usage}[1]{\hyperpage{#1}}
44 \renewcommand*{\main}[1]{\hyperpage{#1}}
45 \IndexPrologue{\section*{\indexname}\markboth{\indexname}{\indexname}}
46 \setcounter{IndexColumns}{2}
47
48 \newcommand*{\sty}[1]{\textsf{#1}}
49 \newcommand*{\opt}[1]{\texttt{#1}\index{#1=\texttt{#1}|main}}
50
51 \RecordChanges
52 \PageIndex
53 \CodelineNumbered
54
55 \begin{document}
56 \DocInput{datetime2-polish.dtx}
57 \end{document}
58 %</driver>
59 %\fi
60 %
61 %\MakeShortVerb{"}
62 %
63 %\title{Polish Module for datetime2 Package}
64 %\author{Nicola L. C. Talbot (inactive)}
65 %\date{2018-08-21 (v1.1)}
66 %\maketitle
67 %
68 %This module is currently unmaintained and may be subject to change.
69 %If you want to volunteer to take over maintenance, contact me at
70 %\url{http://www.dickimaw-books.com/contact.html}
71 %
72 %\begin{abstract}
73 %This is the Polish language module for the \sty{datetime2}
74 %package. If you want to use the settings in this module you must
75 %install it in addition to installing \sty{datetime2}. If you use
76 %\sty{babel} or \sty{polyglossia}, you will need this module to
77 %prevent them from redefining \cs{today}. The \sty{datetime2}
78 % \opt{useregional} setting must be set to "text" or "numeric"
79 % for the language styles to be set.
80 % Alternatively, you can set the style in the document using
81 % \cs{DTMsetstyle}, but this may be changed by \cs{date}\meta{language}
82 % depending on the value of the \opt{useregional} setting.
83 %\end{abstract}
84 %
85 %I've copied the date style from \texttt{babel-polish}'s \cs{today}.
86 %
87 %I don't know if these settings are correct as I can't speak Polish.
88 %In particular, I don't know if the "polish" time style is
89 %correct. Currently this just uses the "default" time style. Please
90 %be aware that this may change. Whoever takes over maintanance
91 %of this module may can change it as appropriate.
92 %
93 %The new maintainer should add the line:
94 %\begin{verbatim}
95 % The Current Maintainer of this work is Name.
96 %\end{verbatim}
97 %to the preamble part in \texttt{datetime2-polish.ins} where Name
98 %is the name of the maintainer(s) and replace
99 %the `inactive' status to `maintained'.
100 %
101 %Currently there is only a regionless style.
102 %
103 %\StopEventually{%
104 %\clearpage
105 %\phantomsection
106 %\addcontentsline{toc}{section}{Change History}%
107 %\PrintChanges
108 %\addcontentsline{toc}{section}{\indexname}%
109 %\PrintIndex}
110 %\section{The Code}
111 %\iffalse
112 % \begin{macrocode}
113 %<*datetime2-polish-utf8.ldf>
114 % \end{macrocode}
115 %\fi
116 %\subsection{UTF-8}
117 %This file contains the settings that use UTF-8 characters. This
118 %file is loaded if XeLaTeX or LuaLaTeX are used. Please make sure
119 %your text editor is set to UTF-8 if you want to view this code.
120 %\changes{1.0}{2015-03-31}{Initial release}
121 % Identify module
122 % \begin{macrocode}
123 \ProvidesDateTimeModule{polish-utf8}[2018/08/21 v1.1]
124 % \end{macrocode}
125 %\begin{macro}{\DTMpolishordinal}
126 % \begin{macrocode}
127 \newcommand*{\DTMpolishordinal}[1]{%
128 \number#1
129 }
130 % \end{macrocode}
131 %\end{macro}
132 %
133 %\begin{macro}{\DTMpolishmonthname}
134 % Polish month names.
135 % \begin{macrocode}
136 \newcommand*{\DTMpolishmonthname}[1]{%
137 \ifcase#1
138 \or
139 stycznia%
140 \or
141 lutego%
142 \or
143 marca%
144 \or
145 kwietnia%
146 \or
147 maja%
148 \or
149 czerwca%
150 \or
151 lipca%
152 \or
153 sierpnia%
154 \or
155 września%
156 \or
157 października%
158 \or
159 listopada%
160 \or
161 grudnia%
162 \fi
163 }
164 % \end{macrocode}
165 %\end{macro}
166 %
167 %\begin{macro}{\DTMpolishMonthname}
168 % As above but capitalize.
169 % \begin{macrocode}
170 \newcommand*{\DTMpolishMonthname}[1]{%
171 \ifcase#1
172 \or
173 Stycznia%
174 \or
175 Lutego%
176 \or
177 Marca%
178 \or
179 Kwietnia%
180 \or
181 Maja%
182 \or
183 Czerwca%
184 \or
185 Lipca%
186 \or
187 Sierpnia%
188 \or
189 Września%
190 \or
191 Października%
192 \or
193 Listopada%
194 \or
195 Grudnia%
196 \fi
197 }
198 % \end{macrocode}
199 %\end{macro}
200 %
201 %If abbreviated dates are supported, short month names should be
202 %likewise provided.
203 %
204 %\begin{macro}{\DTMpolishweekdayname}
205 % Day of week names.
206 % \begin{macrocode}
207 \newcommand*{\DTMpolishweekdayname}[1]{%
208 \ifcase#1
209 poniedziałek%
210 \or
211 wtorek%
212 \or
213 środa%
214 \or
215 czwartek%
216 \or
217 piątek%
218 \or
219 sobota%
220 \or
221 niedziela%
222 \fi
223 }
224 % \end{macrocode}
225 %\end{macro}
226 %
227 %\begin{macro}{\DTMpolishWeekdayname}
228 % As above but start with a capital.
229 % \begin{macrocode}
230 \newcommand*{\DTMpolishWeekdayname}[1]{%
231 \ifcase#1
232 Poniedziałek%
233 \or
234 Wtorek%
235 \or
236 Środa%
237 \or
238 Czwartek%
239 \or
240 Piątek%
241 \or
242 Sobota%
243 \or
244 Niedziela%
245 \fi
246 }
247 % \end{macrocode}
248 %\end{macro}
249 %
250 %\iffalse
251 % \begin{macrocode}
252 %</datetime2-polish-utf8.ldf>
253 % \end{macrocode}
254 %\fi
255 %\iffalse
256 % \begin{macrocode}
257 %<*datetime2-polish-ascii.ldf>
258 % \end{macrocode}
259 %\fi
260 %\subsection{ASCII}
261 %This file contains the settings that use \LaTeX\ commands for
262 %non-ASCII characters. This should be input if neither XeLaTeX nor
263 %LuaLaTeX are used. Even if the user has loaded \sty{inputenc} with
264 %"utf8", this file should still be used not the
265 %\texttt{datetime2-polish-utf8.ldf} file as the non-ASCII
266 %characters are made active in that situation and would need
267 %protecting against expansion.
268 %\changes{1.0}{2015-03-31}{Initial release}
269 % Identify module
270 % \begin{macrocode}
271 \ProvidesDateTimeModule{polish-ascii}[2018/08/21 v1.1]
272 % \end{macrocode}
273 %
274 %If abbreviated dates are supported, short month names should be
275 %likewise provided.
276 %\begin{macro}{\DTMpolishordinal}
277 % \begin{macrocode}
278 \newcommand*{\DTMpolishordinal}[1]{%
279 \number#1
280 }
281 % \end{macrocode}
282 %\end{macro}
283 %
284 %\begin{macro}{\DTMpolishmonthname}
285 % Polish month names.
286 % \begin{macrocode}
287 \newcommand*{\DTMpolishmonthname}[1]{%
288 \ifcase#1
289 \or
290 stycznia%
291 \or
292 lutego%
293 \or
294 marca%
295 \or
296 kwietnia%
297 \or
298 maja%
299 \or
300 czerwca%
301 \or
302 lipca%
303 \or
304 sierpnia%
305 \or
306 wrze\protect\'snia%
307 \or
308 pa\protect\'zdziernika%
309 \or
310 listopada%
311 \or
312 grudnia%
313 \fi
314 }
315 % \end{macrocode}
316 %\end{macro}
317 %
318 %\begin{macro}{\DTMpolishMonthname}
319 % As above but capitalize.
320 % \begin{macrocode}
321 \newcommand*{\DTMpolishMonthname}[1]{%
322 \ifcase#1
323 \or
324 Stycznia%
325 \or
326 Lutego%
327 \or
328 Marca%
329 \or
330 Kwietnia%
331 \or
332 Maja%
333 \or
334 Czerwca%
335 \or
336 Lipca%
337 \or
338 Sierpnia%
339 \or
340 Wrze\protect\'snia%
341 \or
342 Pa\protect\'zdziernika%
343 \or
344 Listopada%
345 \or
346 Grudnia%
347 \fi
348 }
349 % \end{macrocode}
350 %\end{macro}
351 %
352 %\begin{macro}{\DTMpolishweekdayname}
353 % Day of week names.
354 % \begin{macrocode}
355 \newcommand*{\DTMpolishweekdayname}[1]{%
356 \ifcase#1
357 poniedzia\protect\l ek%
358 \or
359 wtorek%
360 \or
361 \protect\'sroda%
362 \or
363 czwartek%
364 \or
365 pi\protect\k atek%
366 \or
367 sobota%
368 \or
369 niedziela%
370 \fi
371 }
372 % \end{macrocode}
373 %\end{macro}
374 %
375 %\begin{macro}{\DTMpolishWeekdayname}
376 % As above but start with a capital.
377 % \begin{macrocode}
378 \newcommand*{\DTMpolishWeekdayname}[1]{%
379 \ifcase#1
380 Poniedzia\protect\l ek%
381 \or
382 Wtorek%
383 \or
384 \protect\'Sroda%
385 \or
386 Czwartek%
387 \or
388 Pi\protect\k atek%
389 \or
390 Sobota%
391 \or
392 Niedziela%
393 \fi
394 }
395 % \end{macrocode}
396 %\end{macro}
397 %
398 %
399 %\iffalse
400 % \begin{macrocode}
401 %</datetime2-polish-ascii.ldf>
402 % \end{macrocode}
403 %\fi
404 %
405 %\subsection{Main Polish Module (\texttt{datetime2-polish.ldf})}
406 %\changes{1.0}{2015-03-31}{Initial release}
407 %
408 %\iffalse
409 % \begin{macrocode}
410 %<*datetime2-polish.ldf>
411 % \end{macrocode}
412 %\fi
413 %
414 % Identify Module
415 % \begin{macrocode}
416 \ProvidesDateTimeModule{polish}[2018/08/21 v1.1]
417 % \end{macrocode}
418 % Need to find out if XeTeX or LuaTeX are being used.
419 % \begin{macrocode}
420 \RequirePackage{ifxetex,ifluatex}
421 % \end{macrocode}
422 % XeTeX and LuaTeX natively support UTF-8, so load
423 % \texttt{polish-utf8} if either of those engines are used
424 % otherwise load \texttt{polish-ascii}.
425 % \begin{macrocode}
426 \ifxetex
427 \RequireDateTimeModule{polish-utf8}
428 \else
429 \ifluatex
430 \RequireDateTimeModule{polish-utf8}
431 \else
432 \RequireDateTimeModule{polish-ascii}
433 \fi
434 \fi
435 % \end{macrocode}
436 %
437 % Define the \texttt{polish} style.
438 % The time style is the same as the "default" style
439 % provided by \sty{datetime2}. This may need correcting. For
440 % example, if a 12 hour style similar to the "englishampm" (from the
441 % "english-base" module) is required.
442 %
443 % Allow the user a way of configuring the "polish" and
444 % "polish-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}{\DTMpolishdaymonthsep}
448 % The separator between the day and month for the text format.
449 % \begin{macrocode}
450 \newcommand*{\DTMpolishdaymonthsep}{%
451 \DTMtexorpdfstring{\protect~}{\space}%
452 }
453 % \end{macrocode}
454 %\end{macro}
455 %
456 %\begin{macro}{\DTMpolishmonthyearsep}
457 % The separator between the month and year for the text format.
458 % \begin{macrocode}
459 \newcommand*{\DTMpolishmonthyearsep}{\space}
460 % \end{macrocode}
461 %\end{macro}
462 %
463 %\begin{macro}{\DTMpolishdatetimesep}
464 % The separator between the date and time blocks in the full format
465 % (either text or numeric).
466 % \begin{macrocode}
467 \newcommand*{\DTMpolishdatetimesep}{\space}
468 % \end{macrocode}
469 %\end{macro}
470 %
471 %\begin{macro}{\DTMpolishtimezonesep}
472 % The separator between the time and zone blocks in the full format
473 % (either text or numeric).
474 % \begin{macrocode}
475 \newcommand*{\DTMpolishtimezonesep}{\space}
476 % \end{macrocode}
477 %\end{macro}
478 %
479 %\begin{macro}{\DTMpolishdatesep}
480 % The separator for the numeric date format.
481 % \begin{macrocode}
482 \newcommand*{\DTMpolishdatesep}{.}
483 % \end{macrocode}
484 %\end{macro}
485 %
486 %\begin{macro}{\DTMpolishtimesep}
487 % The separator for the numeric time format.
488 % \begin{macrocode}
489 \newcommand*{\DTMpolishtimesep}{:}
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{polish}{daymonthsep}{\renewcommand*{\DTMpolishdaymonthsep}{#1}}
497 \DTMdefkey{polish}{monthyearsep}{\renewcommand*{\DTMpolishmonthyearsep}{#1}}
498 \DTMdefkey{polish}{datetimesep}{\renewcommand*{\DTMpolishdatetimesep}{#1}}
499 \DTMdefkey{polish}{timezonesep}{\renewcommand*{\DTMpolishtimezonesep}{#1}}
500 \DTMdefkey{polish}{datesep}{\renewcommand*{\DTMpolishdatesep}{#1}}
501 \DTMdefkey{polish}{timesep}{\renewcommand*{\DTMpolishtimesep}{#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{polish}{mapzone}[true]{}
512 % \end{macrocode}
513 % The default is to use mappings.
514 % \begin{macrocode}
515 \DTMsetbool{polish}{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{polish}{showdayofmonth}[true]{}
522 % \end{macrocode}
523 % The default is to show the day of month.
524 % \begin{macrocode}
525 \DTMsetbool{polish}{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{polish}{showyear}[true]{}
532 % \end{macrocode}
533 % The default is to show the year.
534 % \begin{macrocode}
535 \DTMsetbool{polish}{showyear}{true}
536 % \end{macrocode}
537 %
538 % Define the "polish" style. (TODO: implement day of week?)
539 % \begin{macrocode}
540 \DTMnewstyle
541 {polish}% label
542 {% date style
543 \renewcommand*\DTMdisplaydate[4]{%
544 \DTMifbool{polish}{showdayofmonth}
545 {\DTMpolishordinal{##3}\DTMpolishdaymonthsep}%
546 {}%
547 \DTMpolishmonthname{##2}%
548 \DTMifbool{polish}{showyear}%
549 {%
550 \DTMpolishmonthyearsep
551 \number##1
552 }%
553 {}%
554 }%
555 \renewcommand*\DTMDisplaydate[4]{%
556 \DTMifbool{polish}{showdayofmonth}
557 {%
558 \DTMpolishordinal{##3}\DTMpolishdaymonthsep
559 \DTMpolishmonthname{##2}%
560 }%
561 {%
562 \DTMpolishMonthname{##2}%
563 }%
564 \DTMifbool{polish}{showyear}%
565 {%
566 \DTMpolishmonthyearsep
567 \number##1
568 }%
569 {}%
570 }%
571 }%
572 {% time style (use default)
573 \DTMsettimestyle{default}%
574 }%
575 {% zone style
576 \DTMresetzones
577 \DTMpolishzonemaps
578 \renewcommand*{\DTMdisplayzone}[2]{%
579 \DTMifbool{polish}{mapzone}%
580 {\DTMusezonemapordefault{##1}{##2}}%
581 {%
582 \ifnum##1<0 \else+\fi\DTMtwodigits{##1}%
583 \ifDTMshowzoneminutes\DTMpolishtimesep\DTMtwodigits{##2}\fi
584 }%
585 }%
586 }%
587 {% full style
588 \renewcommand*{\DTMdisplay}[9]{%
589 \ifDTMshowdate
590 \DTMdisplaydate{##1}{##2}{##3}{##4}%
591 \DTMpolishdatetimesep
592 \fi
593 \DTMdisplaytime{##5}{##6}{##7}%
594 \ifDTMshowzone
595 \DTMpolishtimezonesep
596 \DTMdisplayzone{##8}{##9}%
597 \fi
598 }%
599 \renewcommand*{\DTMDisplay}[9]{%
600 \ifDTMshowdate
601 \DTMDisplaydate{##1}{##2}{##3}{##4}%
602 \DTMpolishdatetimesep
603 \fi
604 \DTMdisplaytime{##5}{##6}{##7}%
605 \ifDTMshowzone
606 \DTMpolishtimezonesep
607 \DTMdisplayzone{##8}{##9}%
608 \fi
609 }%
610 }%
611 % \end{macrocode}
612 %
613 % Define numeric style.
614 % \begin{macrocode}
615 \DTMnewstyle
616 {polish-numeric}% label
617 {% date style
618 \renewcommand*\DTMdisplaydate[4]{%
619 \DTMifbool{polish}{showdayofmonth}%
620 {%
621 \number##3 % space intended
622 \DTMpolishdatesep
623 }%
624 {}%
625 \number##2 % space intended
626 \DTMifbool{polish}{showyear}%
627 {%
628 \DTMpolishdatesep
629 \number##1 % space intended
630 }%
631 {}%
632 }%
633 \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}%
634 }%
635 {% time style
636 \renewcommand*\DTMdisplaytime[3]{%
637 \number##1 % space intended
638 \DTMpolishtimesep\DTMtwodigits{##2}%
639 \ifDTMshowseconds\DTMpolishtimesep\DTMtwodigits{##3}\fi
640 }%
641 }%
642 {% zone style
643 \DTMresetzones
644 \DTMpolishzonemaps
645 \renewcommand*{\DTMdisplayzone}[2]{%
646 \DTMifbool{polish}{mapzone}%
647 {\DTMusezonemapordefault{##1}{##2}}%
648 {%
649 \ifnum##1<0 \else+\fi\DTMtwodigits{##1}%
650 \ifDTMshowzoneminutes\DTMpolishtimesep\DTMtwodigits{##2}\fi
651 }%
652 }%
653 }%
654 {% full style
655 \renewcommand*{\DTMdisplay}[9]{%
656 \ifDTMshowdate
657 \DTMdisplaydate{##1}{##2}{##3}{##4}%
658 \DTMpolishdatetimesep
659 \fi
660 \DTMdisplaytime{##5}{##6}{##7}%
661 \ifDTMshowzone
662 \DTMpolishtimezonesep
663 \DTMdisplayzone{##8}{##9}%
664 \fi
665 }%
666 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
667 }
668 % \end{macrocode}
669 %
670 %\begin{macro}{\DTMpolishzonemaps}
671 % The time zone mappings are set through this command, which can be
672 % redefined if extra mappings are required or mappings need to be
673 % removed.
674 % \begin{macrocode}
675 \newcommand*{\DTMpolishzonemaps}{%
676 \DTMdefzonemap{01}{00}{CET}%
677 \DTMdefzonemap{02}{00}{CEST}%
678 }
679 % \end{macrocode}
680 %\end{macro}
681
682 % Switch style according to the \opt{useregional} setting.
683 % \begin{macrocode}
684 \DTMifcaseregional
685 {}% do nothing
686 {\DTMsetstyle{polish}}
687 {\DTMsetstyle{polish-numeric}}
688 % \end{macrocode}
689 %
690 % Redefine \cs{datepolish} (or \cs{date}\meta{dialect}) to prevent
691 % \sty{babel} from resetting \cs{today}. (For this to work,
692 % \sty{babel} must already have been loaded if it's required.)
693 %\changes{1.1}{2018-08-21}{removed spurious space}
694 % \begin{macrocode}
695 \ifcsundef{date\CurrentTrackedDialect}
696 {%
697 \ifundef\datepolish
698 {% do nothing
699 }%
700 {%
701 \def\datepolish{%
702 \DTMifcaseregional
703 {}% do nothing
704 {\DTMsetstyle{polish}}%
705 {\DTMsetstyle{polish-numeric}}%
706 }%
707 }%
708 }%
709 {%
710 \csdef{date\CurrentTrackedDialect}{%
711 \DTMifcaseregional
712 {}% do nothing
713 {\DTMsetstyle{polish}}%
714 {\DTMsetstyle{polish-numeric}}%
715 }%
716 }%
717 % \end{macrocode}
718 %\iffalse
719 % \begin{macrocode}
720 %</datetime2-polish.ldf>
721 % \end{macrocode}
722 %\fi
723 %\Finale
724 \endinput