Debian Codegraph @

texmf-dist/source/latex/datetime2-samin/datetime2-samin.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 Northern Sami Module}]{hyperref}
37
38 \setmainfont{Liberation Serif}
39 \setmonofont{Liberation Mono}
40
41 \CheckSum{332}
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-samin.dtx}
57 \end{document}
58 %</driver>
59 %\fi
60 %
61 %\MakeShortVerb{"}
62 %
63 %\title{Northern Sami 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 Northern Sami 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-samin}'s \cs{today}.
86 %
87 %I don't know if these settings are correct as I can't speak Northern Sami.
88 %In particular, I don't know if the "samin" 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-samin.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-samin-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{samin-utf8}[2018/12/07 v1.1]
124 % \end{macrocode}
125 %\begin{macro}{\DTMsaminordinal}
126 % \begin{macrocode}
127 \newcommand*{\DTMsaminordinal}[1]{%
128 \number#1.\DTMtexorpdfstring{\protect~}{\space}b.%
129 }
130 % \end{macrocode}
131 %\end{macro}
132 %
133 %\begin{macro}{\DTMsaminmonthname}
134 % Northern Sami month names.
135 % \begin{macrocode}
136 \newcommand*{\DTMsaminmonthname}[1]{%
137 \ifcase#1
138 \or
139 ođđajagemánu%
140 \or
141 guovvamánu%
142 \or
143 njukčamánu%
144 \or
145 cuoŋománu%
146 \or
147 miessemánu%
148 \or
149 geassemánu%
150 \or
151 suoidnemánu%
152 \or
153 borgemánu%
154 \or
155 čakčamánu%
156 \or
157 golggotmánu%
158 \or
159 skábmamánu%
160 \or
161 juovlamánu%
162 \fi
163 }
164 % \end{macrocode}
165 %\end{macro}
166 %
167 %\begin{macro}{\DTMsaminMonthname}
168 % As above but capitalize.
169 % \begin{macrocode}
170 \newcommand*{\DTMsaminMonthname}[1]{%
171 \ifcase#1
172 \or
173 Ođđajagemánu%
174 \or
175 Guovvamánu%
176 \or
177 Njukčamánu%
178 \or
179 Cuoŋománu%
180 \or
181 Miessemánu%
182 \or
183 Geassemánu%
184 \or
185 Suoidnemánu%
186 \or
187 Borgemánu%
188 \or
189 Čakčamánu%
190 \or
191 Golggotmánu%
192 \or
193 Skábmamánu%
194 \or
195 Juovlamánu%
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 %\iffalse
205 % \begin{macrocode}
206 %</datetime2-samin-utf8.ldf>
207 % \end{macrocode}
208 %\fi
209 %\iffalse
210 % \begin{macrocode}
211 %<*datetime2-samin-ascii.ldf>
212 % \end{macrocode}
213 %\fi
214 %\subsection{ASCII}
215 %This file contains the settings that use \LaTeX\ commands for
216 %non-ASCII characters. This should be input if neither XeLaTeX nor
217 %LuaLaTeX are used. Even if the user has loaded \sty{inputenc} with
218 %"utf8", this file should still be used not the
219 %\texttt{datetime2-samin-utf8.ldf} file as the non-ASCII
220 %characters are made active in that situation and would need
221 %protecting against expansion.
222 %\changes{1.0}{2015-03-31}{Initial release}
223 % Identify module
224 % \begin{macrocode}
225 \ProvidesDateTimeModule{samin-ascii}[2018/12/07 v1.1]
226 % \end{macrocode}
227 %
228 %If abbreviated dates are supported, short month names should be
229 %likewise provided.
230 %\begin{macro}{\DTMsaminordinal}
231 % \begin{macrocode}
232 \newcommand*{\DTMsaminordinal}[1]{%
233 \number#1.\DTMtexorpdfstring{\protect~}{\space}b.%
234 }
235 % \end{macrocode}
236 %\end{macro}
237 %
238 %\begin{macro}{\DTMsaminmonthname}
239 % Northern Sami month names.
240 % \begin{macrocode}
241 \newcommand*{\DTMsaminmonthname}[1]{%
242 \ifcase#1
243 \or
244 o\protect\dj\protect\dj ajagem\protect\'anu%
245 \or
246 guovvam\protect\'anu%
247 \or
248 njuk\protect\v cam\protect\'anu%
249 \or
250 cuo\protect\ng om\protect\'anu%
251 \or
252 miessem\protect\'anu%
253 \or
254 geassem\protect\'anu%
255 \or
256 suoidnem\protect\'anu%
257 \or
258 borgem\protect\'anu%
259 \or
260 \protect\v cak\protect\v cam\protect\'anu%
261 \or
262 golggotm\protect\'anu%
263 \or
264 sk\protect\'abmam\protect\'anu%
265 \or
266 juovlam\protect\'anu%
267 \fi
268 }
269 % \end{macrocode}
270 %\end{macro}
271 %
272 %\begin{macro}{\DTMsaminMonthname}
273 % As above but capitalize.
274 % \begin{macrocode}
275 \newcommand*{\DTMsaminMonthname}[1]{%
276 \ifcase#1
277 \or
278 O\protect\dj\protect\dj ajagem\protect\'anu%
279 \or
280 Guovvam\protect\'anu%
281 \or
282 Njuk\protect\v cam\protect\'anu%
283 \or
284 Cuo\protect\ng om\protect\'anu%
285 \or
286 Miessem\protect\'anu%
287 \or
288 Geassem\protect\'anu%
289 \or
290 Suoidnem\protect\'anu%
291 \or
292 Borgem\protect\'anu%
293 \or
294 \protect\v Cak\protect\v cam\protect\'anu%
295 \or
296 Golggotm\protect\'anu%
297 \or
298 Sk\protect\'abmam\protect\'anu%
299 \or
300 Juovlam\protect\'anu%
301 \fi
302 }
303 % \end{macrocode}
304 %\end{macro}
305 %
306 %
307 %\iffalse
308 % \begin{macrocode}
309 %</datetime2-samin-ascii.ldf>
310 % \end{macrocode}
311 %\fi
312 %
313 %\subsection{Main Northern Sami Module (\texttt{datetime2-samin.ldf})}
314 %\changes{1.0}{2015-03-31}{Initial release}
315 %
316 %\iffalse
317 % \begin{macrocode}
318 %<*datetime2-samin.ldf>
319 % \end{macrocode}
320 %\fi
321 %
322 % Identify Module
323 % \begin{macrocode}
324 \ProvidesDateTimeModule{samin}[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{samin-utf8} if either of those engines are used
332 % otherwise load \texttt{samin-ascii}.
333 % \begin{macrocode}
334 \ifxetex
335 \RequireDateTimeModule{samin-utf8}
336 \else
337 \ifluatex
338 \RequireDateTimeModule{samin-utf8}
339 \else
340 \RequireDateTimeModule{samin-ascii}
341 \fi
342 \fi
343 % \end{macrocode}
344 %
345 % Define the \texttt{samin} 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 "samin" and
352 % "samin-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}{\DTMsaminmonthdaysep}
356 % The separator between the month and day for the text format.
357 % \begin{macrocode}
358 \newcommand*{\DTMsaminmonthdaysep}{\space}
359 % \end{macrocode}
360 %\end{macro}
361 %
362 %\begin{macro}{\DTMsamindayyearsep}
363 % The separator between the day and year for the text format.
364 % \begin{macrocode}
365 \newcommand*{\DTMsamindayyearsep}{\space}
366 % \end{macrocode}
367 %\end{macro}
368 %
369 %\begin{macro}{\DTMsamindatetimesep}
370 % The separator between the date and time blocks in the full format
371 % (either text or numeric).
372 % \begin{macrocode}
373 \newcommand*{\DTMsamindatetimesep}{\space}
374 % \end{macrocode}
375 %\end{macro}
376 %
377 %\begin{macro}{\DTMsamintimezonesep}
378 % The separator between the time and zone blocks in the full format
379 % (either text or numeric).
380 % \begin{macrocode}
381 \newcommand*{\DTMsamintimezonesep}{\space}
382 % \end{macrocode}
383 %\end{macro}
384 %
385 %\begin{macro}{\DTMsamindatesep}
386 % The separator for the numeric date format.
387 % \begin{macrocode}
388 \newcommand*{\DTMsamindatesep}{.}
389 % \end{macrocode}
390 %\end{macro}
391 %
392 %\begin{macro}{\DTMsamintimesep}
393 % The separator for the numeric time format.
394 % \begin{macrocode}
395 \newcommand*{\DTMsamintimesep}{:}
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{samin}{monthdaysep}{\renewcommand*{\DTMsaminmonthdaysep}{#1}}
403 \DTMdefkey{samin}{dayyearsep}{\renewcommand*{\DTMsamindayyearsep}{#1}}
404 \DTMdefkey{samin}{datetimesep}{\renewcommand*{\DTMsamindatetimesep}{#1}}
405 \DTMdefkey{samin}{timezonesep}{\renewcommand*{\DTMsamintimezonesep}{#1}}
406 \DTMdefkey{samin}{datesep}{\renewcommand*{\DTMsamindatesep}{#1}}
407 \DTMdefkey{samin}{timesep}{\renewcommand*{\DTMsamintimesep}{#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{samin}{mapzone}[true]{}
418 % \end{macrocode}
419 % The default is to use mappings.
420 % \begin{macrocode}
421 \DTMsetbool{samin}{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{samin}{showdayofmonth}[true]{}
428 % \end{macrocode}
429 % The default is to show the day of month.
430 % \begin{macrocode}
431 \DTMsetbool{samin}{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{samin}{showyear}[true]{}
438 % \end{macrocode}
439 % The default is to show the year.
440 % \begin{macrocode}
441 \DTMsetbool{samin}{showyear}{true}
442 % \end{macrocode}
443 %
444 % Define the "samin" style. (TODO: implement day of week?)
445 % \begin{macrocode}
446 \DTMnewstyle
447 {samin}% label
448 {% date style
449 \renewcommand*\DTMdisplaydate[4]{%
450 \DTMsaminmonthname{##2}%
451 \DTMifbool{samin}{showdayofmonth}
452 {%
453 \DTMsaminmonthdaysep
454 \DTMsaminordinal{##3}%
455 }%
456 {}%
457 \DTMifbool{samin}{showyear}%
458 {%
459 \DTMsamindayyearsep
460 \number##1
461 }%
462 {}%
463 }%
464 \renewcommand*\DTMDisplaydate[4]{%
465 \DTMsaminMonthname{##2}%
466 \DTMifbool{samin}{showdayofmonth}
467 {%
468 \DTMsaminmonthdaysep
469 \DTMsaminordinal{##3}%
470 }%
471 {}%
472 \DTMifbool{samin}{showyear}%
473 {%
474 \DTMsamindayyearsep
475 \number##1
476 }%
477 {}%
478 }%
479 }%
480 {% time style (use default)
481 \DTMsettimestyle{default}%
482 }%
483 {% zone style
484 \DTMresetzones
485 \DTMsaminzonemaps
486 \renewcommand*{\DTMdisplayzone}[2]{%
487 \DTMifbool{samin}{mapzone}%
488 {\DTMusezonemapordefault{##1}{##2}}%
489 {%
490 % \end{macrocode}
491 %\changes{1.1}{2018-12-07}{added space before \cs{else}}
492 % \begin{macrocode}
493 \ifnum##1<0 \else+\fi\DTMtwodigits{##1}%
494 \ifDTMshowzoneminutes\DTMsamintimesep\DTMtwodigits{##2}\fi
495 }%
496 }%
497 }%
498 {% full style
499 \renewcommand*{\DTMdisplay}[9]{%
500 \ifDTMshowdate
501 \DTMdisplaydate{##1}{##2}{##3}{##4}%
502 \DTMsamindatetimesep
503 \fi
504 \DTMdisplaytime{##5}{##6}{##7}%
505 \ifDTMshowzone
506 \DTMsamintimezonesep
507 \DTMdisplayzone{##8}{##9}%
508 \fi
509 }%
510 \renewcommand*{\DTMDisplay}[9]{%
511 \ifDTMshowdate
512 \DTMDisplaydate{##1}{##2}{##3}{##4}%
513 \DTMsamindatetimesep
514 \fi
515 \DTMdisplaytime{##5}{##6}{##7}%
516 \ifDTMshowzone
517 \DTMsamintimezonesep
518 \DTMdisplayzone{##8}{##9}%
519 \fi
520 }%
521 }%
522 % \end{macrocode}
523 %
524 % Define numeric style.
525 % \begin{macrocode}
526 \DTMnewstyle
527 {samin-numeric}% label
528 {% date style
529 \renewcommand*\DTMdisplaydate[4]{%
530 \DTMifbool{samin}{showdayofmonth}%
531 {%
532 \number##3 % space intended
533 \DTMsamindatesep
534 }%
535 {}%
536 \number##2 % space intended
537 \DTMifbool{samin}{showyear}%
538 {%
539 \DTMsamindatesep
540 \number##1 % space intended
541 }%
542 {}%
543 }%
544 \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}%
545 }%
546 {% time style
547 \renewcommand*\DTMdisplaytime[3]{%
548 \number##1
549 \DTMsamintimesep\DTMtwodigits{##2}%
550 \ifDTMshowseconds\DTMsamintimesep\DTMtwodigits{##3}\fi
551 }%
552 }%
553 {% zone style
554 \DTMresetzones
555 \DTMsaminzonemaps
556 \renewcommand*{\DTMdisplayzone}[2]{%
557 \DTMifbool{samin}{mapzone}%
558 {\DTMusezonemapordefault{##1}{##2}}%
559 {%
560 % \end{macrocode}
561 %\changes{1.1}{2018-12-07}{added space before \cs{else}}
562 % \begin{macrocode}
563 \ifnum##1<0 \else+\fi\DTMtwodigits{##1}%
564 \ifDTMshowzoneminutes\DTMsamintimesep\DTMtwodigits{##2}\fi
565 }%
566 }%
567 }%
568 {% full style
569 \renewcommand*{\DTMdisplay}[9]{%
570 \ifDTMshowdate
571 \DTMdisplaydate{##1}{##2}{##3}{##4}%
572 \DTMsamindatetimesep
573 \fi
574 \DTMdisplaytime{##5}{##6}{##7}%
575 \ifDTMshowzone
576 \DTMsamintimezonesep
577 \DTMdisplayzone{##8}{##9}%
578 \fi
579 }%
580 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
581 }
582 % \end{macrocode}
583 %
584 %\begin{macro}{\DTMsaminzonemaps}
585 % The time zone mappings are set through this command, which can be
586 % redefined if extra mappings are required or mappings need to be
587 % removed. Daylight saving isn't taken into account.
588 % \begin{macrocode}
589 \newcommand*{\DTMsaminzonemaps}{%
590 \DTMdefzonemap{01}{00}{CET}%
591 \DTMdefzonemap{02}{00}{EET}%
592 }
593 % \end{macrocode}
594 %\end{macro}
595
596 % Switch style according to the \opt{useregional} setting.
597 % \begin{macrocode}
598 \DTMifcaseregional
599 {}% do nothing
600 {\DTMsetstyle{samin}}
601 {\DTMsetstyle{samin-numeric}}
602 % \end{macrocode}
603 %
604 % Redefine \cs{datesamin} (or \cs{date}\meta{dialect}) to prevent
605 % \sty{babel} from resetting \cs{today}. (For this to work,
606 % \sty{babel} must already have been loaded if it's required.)
607 %\changes{1.1}{2018-12-07}{removed spurious space}
608 % \begin{macrocode}
609 \ifcsundef{date\CurrentTrackedDialect}
610 {%
611 \ifundef\datesamin
612 {% do nothing
613 }%
614 {%
615 \def\datesamin{%
616 \DTMifcaseregional
617 {}% do nothing
618 {\DTMsetstyle{samin}}%
619 {\DTMsetstyle{samin-numeric}}%
620 }%
621 }%
622 }%
623 {%
624 \csdef{date\CurrentTrackedDialect}{%
625 \DTMifcaseregional
626 {}% do nothing
627 {\DTMsetstyle{samin}}%
628 {\DTMsetstyle{samin-numeric}}%
629 }%
630 }%
631 % \end{macrocode}
632 %\iffalse
633 % \begin{macrocode}
634 %</datetime2-samin.ldf>
635 % \end{macrocode}
636 %\fi
637 %\Finale
638 \endinput