Debian Codegraph @

texmf-dist/source/latex/datetime2-icelandic/datetime2-icelandic.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) 2018-2022 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 pdfauthor={Nicola L.C. Talbot},
34 pdftitle={datetime2.sty Icelandic Module}]{hyperref}
35
36 \setmainfont{Liberation Serif}
37 \setmonofont{Liberation Mono}
38
39 \CheckSum{300}
40
41 \setcounter{IndexColumns}{2}
42
43 \newcommand*{\sty}[1]{\textsf{#1}}
44 \newcommand*{\opt}[1]{\texttt{#1}}
45
46 \RecordChanges
47 \PageIndex
48 \CodelineNumbered
49
50 \begin{document}
51 \DocInput{datetime2-icelandic.dtx}
52 \end{document}
53 %</driver>
54 %\fi
55 %
56 %\MakeShortVerb{"}
57 %
58 %\title{Icelandic Module for datetime2 Package}
59 %\author{Nicola L. C. Talbot (inactive)}
60 %\date{2022-12-06 (v1.2)}
61 %\maketitle
62 %
63 %This module is currently unmaintained and may be subject to change.
64 %If you want to volunteer to take over maintenance, contact me at
65 %\url{https://www.dickimaw-books.com/contact.html}
66 %
67 %\begin{abstract}
68 %This is the Icelandic language module for the \sty{datetime2}
69 %package. If you want to use the settings in this module you must
70 %install it in addition to installing \sty{datetime2}. If you use
71 %\sty{babel} or \sty{polyglossia}, you will need this module to
72 %prevent them from redefining \cs{today}. The \sty{datetime2}
73 % \opt{useregional} setting must be set to "text" or "numeric"
74 % for the language styles to be set.
75 % Alternatively, you can set the style in the document using
76 % \cs{DTMsetstyle}, but this may be changed by \cs{date}\meta{language}
77 % depending on the value of the \opt{useregional} setting.
78 %\end{abstract}
79 %
80 %I've copied the date style from \texttt{babel-icelandic}'s \cs{today}.
81 %
82 %I don't know if these settings are correct as I can't speak Icelandic.
83 %In particular, I don't know if the "icelandic" time style is
84 %correct. Currently this just uses the "default" time style. Please
85 %be aware that this may change. Whoever takes over maintanance
86 %of this module may can change it as appropriate.
87 %
88 %The new maintainer should add the line:
89 %\begin{verbatim}
90 % The Current Maintainer of this work is Name.
91 %\end{verbatim}
92 %to the preamble part in \texttt{datetime2-icelandic.ins} where Name
93 %is the name of the maintainer(s) and replace
94 %the `inactive' status to `maintained'.
95 %
96 %Currently there is only a regionless style.
97 %
98 %\StopEventually{%
99 %\clearpage
100 %\phantomsection
101 %\PrintChanges
102 %\PrintIndex}
103 %\section{The Code}
104 %\iffalse
105 % \begin{macrocode}
106 %<*datetime2-icelandic-utf8.ldf>
107 % \end{macrocode}
108 %\fi
109 %\subsection{UTF-8}
110 %This file contains the settings that use UTF-8 characters. This
111 %file is loaded if XeLaTeX or LuaLaTeX are used. Please make sure
112 %your text editor is set to UTF-8 if you want to view this code.
113 %\changes{1.0}{2015-03-30}{Initial release}
114 % Identify module
115 % \begin{macrocode}
116 \ProvidesDateTimeModule{icelandic-utf8}[2022/12/06 v1.2]
117 % \end{macrocode}
118 %\begin{macro}{\DTMicelandicordinal}
119 % \begin{macrocode}
120 \newcommand*{\DTMicelandicordinal}[1]{%
121 \number#1.%
122 }
123 % \end{macrocode}
124 %\end{macro}
125 %
126 %
127 %\begin{macro}{\DTMicelandicmonthname}
128 % Icelandic month names.
129 %\changes{1.2}{2022-12-06}{corrected desember}
130 % \begin{macrocode}
131 \newcommand*{\DTMicelandicmonthname}[1]{%
132 \ifcase#1
133 \or
134 janúar%
135 \or
136 febrúar%
137 \or
138 mars%
139 \or
140 apríl%
141 \or
142 maí%
143 \or
144 júní%
145 \or
146 júlí%
147 \or
148 ágúst%
149 \or
150 september%
151 \or
152 október%
153 \or
154 nóvember%
155 \or
156 desember%
157 \fi
158 }
159 % \end{macrocode}
160 %\end{macro}
161 %
162 %\begin{macro}{\DTMicelandicMonthname}
163 % As above but capitalize.
164 %\changes{1.2}{2022-12-06}{corrected Desember}
165 % \begin{macrocode}
166 \newcommand*{\DTMicelandicMonthname}[1]{%
167 \ifcase#1
168 \or
169 Janúar%
170 \or
171 Febrúar%
172 \or
173 Mars%
174 \or
175 Apríl%
176 \or
177 Maí%
178 \or
179 Júní%
180 \or
181 Júlí%
182 \or
183 Ágúst%
184 \or
185 September%
186 \or
187 Október%
188 \or
189 Nóvember%
190 \or
191 Desember%
192 \fi
193 }
194 % \end{macrocode}
195 %\end{macro}
196 %
197 %If abbreviated dates are supported, short month names should be
198 %likewise provided.
199 %
200 %\iffalse
201 % \begin{macrocode}
202 %</datetime2-icelandic-utf8.ldf>
203 % \end{macrocode}
204 %\fi
205 %\iffalse
206 % \begin{macrocode}
207 %<*datetime2-icelandic-ascii.ldf>
208 % \end{macrocode}
209 %\fi
210 %\subsection{ASCII}
211 %This file contains the settings that use \LaTeX\ commands for
212 %non-ASCII characters. This should be input if neither XeLaTeX nor
213 %LuaLaTeX are used. Even if the user has loaded \sty{inputenc} with
214 %"utf8", this file should still be used not the
215 %\texttt{datetime2-icelandic-utf8.ldf} file as the non-ASCII
216 %characters are made active in that situation and would need
217 %protecting against expansion.
218 %\changes{1.0}{2015-03-30}{Initial release}
219 % Identify module
220 % \begin{macrocode}
221 \ProvidesDateTimeModule{icelandic-ascii}[2022/12/06 v1.2]
222 % \end{macrocode}
223 %
224 %If abbreviated dates are supported, short month names should be
225 %likewise provided.
226 %\begin{macro}{\DTMicelandicordinal}
227 % \begin{macrocode}
228 \newcommand*{\DTMicelandicordinal}[1]{%
229 \number#1.%
230 }
231 % \end{macrocode}
232 %\end{macro}
233 %
234 %\begin{macro}{\DTMicelandicmonthname}
235 % Icelandic month names.
236 %\changes{1.2}{2022-12-06}{corrected desember}
237 % \begin{macrocode}
238 \newcommand*{\DTMicelandicmonthname}[1]{%
239 \ifcase#1
240 \or
241 jan\protect\'uar%
242 \or
243 febr\protect\'uar%
244 \or
245 mars%
246 \or
247 apr\protect\'il%
248 \or
249 ma\protect\'i%
250 \or
251 j\protect\'un\protect\'i%
252 \or
253 j\protect\'ul\protect\'i%
254 \or
255 \protect\'ag\protect\'ust%
256 \or
257 september%
258 \or
259 okt\protect\'ober%
260 \or
261 n\protect\'ovember%
262 \or
263 desember%
264 \fi
265 }
266 % \end{macrocode}
267 %\end{macro}
268 %
269 %\begin{macro}{\DTMicelandicMonthname}
270 %\changes{1.2}{2022-12-06}{corrected Desember}
271 % As above but capitalize.
272 % \begin{macrocode}
273 \newcommand*{\DTMicelandicMonthname}[1]{%
274 \ifcase#1
275 \or
276 Jan\protect\'uar%
277 \or
278 Febr\protect\'uar%
279 \or
280 Mars%
281 \or
282 Apr\protect\'il%
283 \or
284 Ma\protect\'i%
285 \or
286 J\protect\'un\protect\'i%
287 \or
288 J\protect\'ul\protect\'i%
289 \or
290 \protect\'Ag\protect\'ust%
291 \or
292 September%
293 \or
294 Okt\protect\'ober%
295 \or
296 N\protect\'ovember%
297 \or
298 Desember%
299 \fi
300 }
301 % \end{macrocode}
302 %\end{macro}
303 %
304 %
305 %\iffalse
306 % \begin{macrocode}
307 %</datetime2-icelandic-ascii.ldf>
308 % \end{macrocode}
309 %\fi
310 %
311 %\subsection{Main Icelandic Module (\texttt{datetime2-icelandic.ldf})}
312 %\changes{1.0}{2015-03-30}{Initial release}
313 %
314 %\iffalse
315 % \begin{macrocode}
316 %<*datetime2-icelandic.ldf>
317 % \end{macrocode}
318 %\fi
319 %
320 % Identify Module
321 % \begin{macrocode}
322 \ProvidesDateTimeModule{icelandic}[2022/12/06 v1.2]
323 % \end{macrocode}
324 % Need to find out if XeTeX or LuaTeX are being used.
325 %\changes{1.2}{2022-12-06}{switched to iftex}
326 % \begin{macrocode}
327 \RequirePackage{iftex}
328 % \end{macrocode}
329 % XeTeX and LuaTeX natively support UTF-8, so load
330 % \texttt{icelandic-utf8} if either of those engines are used
331 % otherwise load \texttt{icelandic-ascii}.
332 % Modern LaTeX kernels have much better support for UTF-8, so
333 % a test could also be added to determine if \cs{inputencoding} is
334 % \texttt{utf8}.
335 % \begin{macrocode}
336 \ifxetex
337 \RequireDateTimeModule{icelandic-utf8}
338 \else
339 \ifluatex
340 \RequireDateTimeModule{icelandic-utf8}
341 \else
342 \RequireDateTimeModule{icelandic-ascii}
343 \fi
344 \fi
345 % \end{macrocode}
346 %
347 % Define the \texttt{icelandic} style.
348 % The time style is the same as the "default" style
349 % provided by \sty{datetime2}. This may need correcting. For
350 % example, if a 12 hour style similar to the "englishampm" (from the
351 % "english-base" module) is required.
352 %
353 % Allow the user a way of configuring the "icelandic" and
354 % "icelandic-numeric" styles. This doesn't use the package wide
355 % separators such as
356 % \cs{dtm@datetimesep} in case other date formats are also required.
357 %\begin{macro}{\DTMicelandicdaymonthsep}
358 % The separator between the day and month for the text format.
359 % \begin{macrocode}
360 \newcommand*{\DTMicelandicdaymonthsep}{%
361 \DTMtexorpdfstring{\protect~}{\space}%
362 }
363 % \end{macrocode}
364 %\end{macro}
365 %
366 %\begin{macro}{\DTMicelandicmonthyearsep}
367 % The separator between the month and year for the text format.
368 % \begin{macrocode}
369 \newcommand*{\DTMicelandicmonthyearsep}{\space}
370 % \end{macrocode}
371 %\end{macro}
372 %
373 %\begin{macro}{\DTMicelandicdatetimesep}
374 % The separator between the date and time blocks in the full format
375 % (either text or numeric).
376 % \begin{macrocode}
377 \newcommand*{\DTMicelandicdatetimesep}{\space}
378 % \end{macrocode}
379 %\end{macro}
380 %
381 %\begin{macro}{\DTMicelandictimezonesep}
382 % The separator between the time and zone blocks in the full format
383 % (either text or numeric).
384 % \begin{macrocode}
385 \newcommand*{\DTMicelandictimezonesep}{\space}
386 % \end{macrocode}
387 %\end{macro}
388 %
389 %\begin{macro}{\DTMicelandicdatesep}
390 % The separator for the numeric date format.
391 % \begin{macrocode}
392 \newcommand*{\DTMicelandicdatesep}{/}
393 % \end{macrocode}
394 %\end{macro}
395 %
396 %\begin{macro}{\DTMicelandictimesep}
397 % The separator for the numeric time format.
398 % \begin{macrocode}
399 \newcommand*{\DTMicelandictimesep}{:}
400 % \end{macrocode}
401 %\end{macro}
402 %
403 %Provide keys that can be used in \cs{DTMlangsetup} to set these
404 %separators.
405 % \begin{macrocode}
406 \DTMdefkey{icelandic}{daymonthsep}{\renewcommand*{\DTMicelandicdaymonthsep}{#1}}
407 \DTMdefkey{icelandic}{monthyearsep}{\renewcommand*{\DTMicelandicmonthyearsep}{#1}}
408 \DTMdefkey{icelandic}{datetimesep}{\renewcommand*{\DTMicelandicdatetimesep}{#1}}
409 \DTMdefkey{icelandic}{timezonesep}{\renewcommand*{\DTMicelandictimezonesep}{#1}}
410 \DTMdefkey{icelandic}{datesep}{\renewcommand*{\DTMicelandicdatesep}{#1}}
411 \DTMdefkey{icelandic}{timesep}{\renewcommand*{\DTMicelandictimesep}{#1}}
412 % \end{macrocode}
413 %
414 % TODO: provide a boolean key to switch between full and abbreviated
415 % formats if appropriate. (I don't know how the date should be
416 % abbreviated.)
417 %
418 % Define a boolean key that determines if the time zone mappings
419 % should be used.
420 % \begin{macrocode}
421 \DTMdefboolkey{icelandic}{mapzone}[true]{}
422 % \end{macrocode}
423 % The default is to use mappings.
424 % \begin{macrocode}
425 \DTMsetbool{icelandic}{mapzone}{true}
426 % \end{macrocode}
427 %
428 % Define a boolean key that determines if the day of month should be
429 % displayed.
430 % \begin{macrocode}
431 \DTMdefboolkey{icelandic}{showdayofmonth}[true]{}
432 % \end{macrocode}
433 % The default is to show the day of month.
434 % \begin{macrocode}
435 \DTMsetbool{icelandic}{showdayofmonth}{true}
436 % \end{macrocode}
437 %
438 % Define a boolean key that determines if the year should be
439 % displayed.
440 % \begin{macrocode}
441 \DTMdefboolkey{icelandic}{showyear}[true]{}
442 % \end{macrocode}
443 % The default is to show the year.
444 % \begin{macrocode}
445 \DTMsetbool{icelandic}{showyear}{true}
446 % \end{macrocode}
447 %
448 % Define the "icelandic" style. (TODO: implement day of week?)
449 % \begin{macrocode}
450 \DTMnewstyle
451 {icelandic}% label
452 {% date style
453 \renewcommand*\DTMdisplaydate[4]{%
454 \DTMifbool{icelandic}{showdayofmonth}
455 {\DTMicelandicordinal{##3}\DTMicelandicdaymonthsep}%
456 {}%
457 \DTMicelandicmonthname{##2}%
458 \DTMifbool{icelandic}{showyear}%
459 {%
460 \DTMicelandicmonthyearsep
461 \number##1
462 }%
463 {}%
464 }%
465 \renewcommand*\DTMDisplaydate[4]{%
466 \DTMifbool{icelandic}{showdayofmonth}
467 {%
468 \DTMicelandicordinal{##3}\DTMicelandicdaymonthsep
469 \DTMicelandicmonthname{##2}%
470 }%
471 {%
472 \DTMicelandicMonthname{##2}%
473 }%
474 \DTMifbool{icelandic}{showyear}%
475 {%
476 \DTMicelandicmonthyearsep
477 \number##1
478 }%
479 {}%
480 }%
481 }%
482 {% time style (use default)
483 \DTMsettimestyle{default}%
484 }%
485 {% zone style
486 \DTMresetzones
487 \DTMicelandiczonemaps
488 \renewcommand*{\DTMdisplayzone}[2]{%
489 \DTMifbool{icelandic}{mapzone}%
490 {\DTMusezonemapordefault{##1}{##2}}%
491 {%
492 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
493 \ifDTMshowzoneminutes\DTMicelandictimesep\DTMtwodigits{##2}\fi
494 }%
495 }%
496 }%
497 {% full style
498 \renewcommand*{\DTMdisplay}[9]{%
499 \ifDTMshowdate
500 \DTMdisplaydate{##1}{##2}{##3}{##4}%
501 \DTMicelandicdatetimesep
502 \fi
503 \DTMdisplaytime{##5}{##6}{##7}%
504 \ifDTMshowzone
505 \DTMicelandictimezonesep
506 \DTMdisplayzone{##8}{##9}%
507 \fi
508 }%
509 \renewcommand*{\DTMDisplay}[9]{%
510 \ifDTMshowdate
511 \DTMDisplaydate{##1}{##2}{##3}{##4}%
512 \DTMicelandicdatetimesep
513 \fi
514 \DTMdisplaytime{##5}{##6}{##7}%
515 \ifDTMshowzone
516 \DTMicelandictimezonesep
517 \DTMdisplayzone{##8}{##9}%
518 \fi
519 }%
520 }%
521 % \end{macrocode}
522 %
523 % Define numeric style.
524 % \begin{macrocode}
525 \DTMnewstyle
526 {icelandic-numeric}% label
527 {% date style
528 \renewcommand*\DTMdisplaydate[4]{%
529 \DTMifbool{icelandic}{showdayofmonth}%
530 {%
531 \number##3 % space intended
532 \DTMicelandicdatesep
533 }%
534 {}%
535 \number##2 % space intended
536 \DTMifbool{icelandic}{showyear}%
537 {%
538 \DTMicelandicdatesep
539 \number##1 % space intended
540 }%
541 {}%
542 }%
543 \renewcommand*{\DTMDisplaydate}{\DTMdisplaydate}%
544 }%
545 {% time style
546 \renewcommand*\DTMdisplaytime[3]{%
547 \number##1 % space intended
548 \DTMicelandictimesep\DTMtwodigits{##2}%
549 \ifDTMshowseconds\DTMicelandictimesep\DTMtwodigits{##3}\fi
550 }%
551 }%
552 {% zone style
553 \DTMresetzones
554 \DTMicelandiczonemaps
555 \renewcommand*{\DTMdisplayzone}[2]{%
556 \DTMifbool{icelandic}{mapzone}%
557 {\DTMusezonemapordefault{##1}{##2}}%
558 {%
559 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
560 \ifDTMshowzoneminutes\DTMicelandictimesep\DTMtwodigits{##2}\fi
561 }%
562 }%
563 }%
564 {% full style
565 \renewcommand*{\DTMdisplay}[9]{%
566 \ifDTMshowdate
567 \DTMdisplaydate{##1}{##2}{##3}{##4}%
568 \DTMicelandicdatetimesep
569 \fi
570 \DTMdisplaytime{##5}{##6}{##7}%
571 \ifDTMshowzone
572 \DTMicelandictimezonesep
573 \DTMdisplayzone{##8}{##9}%
574 \fi
575 }%
576 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
577 }
578 % \end{macrocode}
579 %
580 %\begin{macro}{\DTMicelandiczonemaps}
581 % The time zone mappings are set through this command, which can be
582 % redefined if extra mappings are required or mappings need to be
583 % removed.
584 % \begin{macrocode}
585 \newcommand*{\DTMicelandiczonemaps}{%
586 \DTMdefzonemap{00}{00}{GMT}%
587 }
588 % \end{macrocode}
589 %\end{macro}
590
591 % Switch style according to the \opt{useregional} setting.
592 % \begin{macrocode}
593 \DTMifcaseregional
594 {}% do nothing
595 {\DTMsetstyle{icelandic}}
596 {\DTMsetstyle{icelandic-numeric}}
597 % \end{macrocode}
598 %
599 % Redefine \cs{dateicelandic} (or \cs{date}\meta{dialect}) to prevent
600 % \sty{babel} from resetting \cs{today}. (For this to work,
601 % \sty{babel} must already have been loaded if it's required.)
602 %\changes{1.1}{2018-04-25}{removed spurious space}
603 % \begin{macrocode}
604 \ifcsundef{date\CurrentTrackedDialect}
605 {%
606 \ifundef\dateicelandic
607 {% do nothing
608 }%
609 {%
610 \def\dateicelandic{%
611 \DTMifcaseregional
612 {}% do nothing
613 {\DTMsetstyle{icelandic}}%
614 {\DTMsetstyle{icelandic-numeric}}%
615 }%
616 }%
617 }%
618 {%
619 \csdef{date\CurrentTrackedDialect}{%
620 \DTMifcaseregional
621 {}% do nothing
622 {\DTMsetstyle{icelandic}}%
623 {\DTMsetstyle{icelandic-numeric}}%
624 }%
625 }%
626 % \end{macrocode}
627 %\iffalse
628 % \begin{macrocode}
629 %</datetime2-icelandic.ldf>
630 % \end{macrocode}
631 %\fi
632 %\Finale
633 \endinput