Debian Codegraph @

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