Debian Codegraph @

texmf-dist/source/latex/datetime2-danish/datetime2-danish.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 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 Danish Module}]{hyperref}
37
38 \setmainfont{Liberation Serif}
39 \setmonofont{Liberation Mono}
40
41 \CheckSum{301}
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-danish.dtx}
57 \end{document}
58 %</driver>
59 %\fi
60 %
61 %\MakeShortVerb{"}
62 %
63 %\title{Danish Module for datetime2 Package}
64 %\author{Nicola L. C. Talbot (inactive)}
65 %\date{2018-03-19 (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 Danish 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-danish}'s \cs{today}.
86 %
87 %I don't know if these settings are correct as I can't speak Danish.
88 %In particular, I don't know if the "danish" 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-danish.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-danish-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-30}{Initial release}
121 % Identify module
122 % \begin{macrocode}
123 \ProvidesDateTimeModule{danish-utf8}[2018/03/19 v1.1]
124 % \end{macrocode}
125 %\begin{macro}{\DTMdanishordinal}
126 % \begin{macrocode}
127 \newcommand*{\DTMdanishordinal}[1]{%
128 \number#1.%
129 }
130 % \end{macrocode}
131 %\end{macro}
132 %
133 %
134 %\begin{macro}{\DTMdanishmonthname}
135 % Danish month names.
136 % \begin{macrocode}
137 \newcommand*{\DTMdanishmonthname}[1]{%
138 \ifcase#1
139 \or
140 januar%
141 \or
142 februar%
143 \or
144 marts%
145 \or
146 april%
147 \or
148 maj%
149 \or
150 juni%
151 \or
152 juli%
153 \or
154 august%
155 \or
156 september%
157 \or
158 oktober%
159 \or
160 november%
161 \or
162 december%
163 \fi
164 }
165 % \end{macrocode}
166 %\end{macro}
167 %
168 %\begin{macro}{\DTMdanishMonthname}
169 % As above but capitalize.
170 % \begin{macrocode}
171 \newcommand*{\DTMdanishMonthname}[1]{%
172 \ifcase#1
173 \or
174 Januar%
175 \or
176 Februar%
177 \or
178 Marts%
179 \or
180 April%
181 \or
182 Maj%
183 \or
184 Juni%
185 \or
186 Juli%
187 \or
188 August%
189 \or
190 September%
191 \or
192 Oktober%
193 \or
194 November%
195 \or
196 December%
197 \fi
198 }
199 % \end{macrocode}
200 %\end{macro}
201 %
202 %If abbreviated dates are supported, short month names should be
203 %likewise provided.
204 %
205 %\begin{macro}{\DTMdanishweekdayname}
206 % Danish day of week names.
207 % \begin{macrocode}
208 \newcommand*{\DTMdanishweekdayname}[1]{%
209 \ifcase#1
210 mandag%
211 \or
212 tirsdag%
213 \or
214 onsdag%
215 \or
216 torsdag%
217 \or
218 fredag%
219 \or
220 lørdag%
221 \or
222 søndag%
223 \fi
224 }
225 % \end{macrocode}
226 %\end{macro}
227 %
228 %\begin{macro}{\DTMdanishWeekdayname}
229 % As above but start with a capital.
230 % \begin{macrocode}
231 \newcommand*{\DTMdanishWeekdayname}[1]{%
232 \ifcase#1
233 Mandag%
234 \or
235 Tirsdag%
236 \or
237 Onsdag%
238 \or
239 Torsdag%
240 \or
241 Fredag%
242 \or
243 Lørdag%
244 \or
245 Søndag%
246 \fi
247 }
248 % \end{macrocode}
249 %\end{macro}
250 %
251 %\iffalse
252 % \begin{macrocode}
253 %</datetime2-danish-utf8.ldf>
254 % \end{macrocode}
255 %\fi
256 %\iffalse
257 % \begin{macrocode}
258 %<*datetime2-danish-ascii.ldf>
259 % \end{macrocode}
260 %\fi
261 %\subsection{ASCII}
262 %This file contains the settings that use \LaTeX\ commands for
263 %non-ASCII characters. This should be input if neither XeLaTeX nor
264 %LuaLaTeX are used. Even if the user has loaded \sty{inputenc} with
265 %"utf8", this file should still be used not the
266 %\texttt{datetime2-danish-utf8.ldf} file as the non-ASCII
267 %characters are made active in that situation and would need
268 %protecting against expansion.
269 %\changes{1.0}{2015-03-30}{Initial release}
270 % Identify module
271 % \begin{macrocode}
272 \ProvidesDateTimeModule{danish-ascii}[2018/03/19 v1.1]
273 % \end{macrocode}
274 %
275 %If abbreviated dates are supported, short month names should be
276 %likewise provided.
277 %\begin{macro}{\DTMdanishordinal}
278 % \begin{macrocode}
279 \newcommand*{\DTMdanishordinal}[1]{%
280 \number#1.%
281 }
282 % \end{macrocode}
283 %\end{macro}
284 %
285 %\begin{macro}{\DTMdanishmonthname}
286 % Danish month names.
287 % \begin{macrocode}
288 \newcommand*{\DTMdanishmonthname}[1]{%
289 \ifcase#1
290 \or
291 januar%
292 \or
293 februar%
294 \or
295 marts%
296 \or
297 april%
298 \or
299 maj%
300 \or
301 juni%
302 \or
303 juli%
304 \or
305 august%
306 \or
307 september%
308 \or
309 oktober%
310 \or
311 november%
312 \or
313 december%
314 \fi
315 }
316 % \end{macrocode}
317 %\end{macro}
318 %
319 %\begin{macro}{\DTMdanishMonthname}
320 % As above but capitalize.
321 % \begin{macrocode}
322 \newcommand*{\DTMdanishMonthname}[1]{%
323 \ifcase#1
324 \or
325 Januar%
326 \or
327 Februar%
328 \or
329 Marts%
330 \or
331 April%
332 \or
333 Maj%
334 \or
335 Juni%
336 \or
337 Juli%
338 \or
339 August%
340 \or
341 September%
342 \or
343 Oktober%
344 \or
345 November%
346 \or
347 December%
348 \fi
349 }
350 % \end{macrocode}
351 %\end{macro}
352 %
353 %\begin{macro}{\DTMdanishweekdayname}
354 % Danish day of week names.
355 % \begin{macrocode}
356 \newcommand*{\DTMdanishweekdayname}[1]{%
357 \ifcase#1
358 mandag%
359 \or
360 tirsdag%
361 \or
362 onsdag%
363 \or
364 torsdag%
365 \or
366 fredag%
367 \or
368 l\protect\o rdag%
369 \or
370 s\protect\o ndag%
371 \fi
372 }
373 % \end{macrocode}
374 %\end{macro}
375 %
376 %\begin{macro}{\DTMdanishWeekdayname}
377 % As above but start with a capital.
378 % \begin{macrocode}
379 \newcommand*{\DTMdanishWeekdayname}[1]{%
380 \ifcase#1
381 Mandag%
382 \or
383 Tirsdag%
384 \or
385 Onsdag%
386 \or
387 Torsdag%
388 \or
389 Fredag%
390 \or
391 L\protect\o rdag%
392 \or
393 S\protect\o ndag%
394 \fi
395 }
396 % \end{macrocode}
397 %\end{macro}
398 %
399 %
400 %\iffalse
401 % \begin{macrocode}
402 %</datetime2-danish-ascii.ldf>
403 % \end{macrocode}
404 %\fi
405 %
406 %\subsection{Main Danish Module (\texttt{datetime2-danish.ldf})}
407 %\changes{1.0}{2015-03-30}{Initial release}
408 %
409 %\iffalse
410 % \begin{macrocode}
411 %<*datetime2-danish.ldf>
412 % \end{macrocode}
413 %\fi
414 %
415 % Identify Module
416 % \begin{macrocode}
417 \ProvidesDateTimeModule{danish}[2018/03/19 v1.1]
418 % \end{macrocode}
419 % Need to find out if XeTeX or LuaTeX are being used.
420 % \begin{macrocode}
421 \RequirePackage{ifxetex,ifluatex}
422 % \end{macrocode}
423 % XeTeX and LuaTeX natively support UTF-8, so load
424 % \texttt{danish-utf8} if either of those engines are used
425 % otherwise load \texttt{danish-ascii}.
426 % \begin{macrocode}
427 \ifxetex
428 \RequireDateTimeModule{danish-utf8}
429 \else
430 \ifluatex
431 \RequireDateTimeModule{danish-utf8}
432 \else
433 \RequireDateTimeModule{danish-ascii}
434 \fi
435 \fi
436 % \end{macrocode}
437 %
438 % Define the \texttt{danish} style.
439 % The time style is the same as the "default" style
440 % provided by \sty{datetime2}. This may need correcting. For
441 % example, if a 12 hour style similar to the "englishampm" (from the
442 % "english-base" module) is required.
443 %
444 % Allow the user a way of configuring the "danish" and
445 % "danish-numeric" styles. This doesn't use the package wide
446 % separators such as
447 % \cs{dtm@datetimesep} in case other date formats are also required.
448 %\begin{macro}{\DTMdanishdaymonthsep}
449 % The separator between the day and month for the text format.
450 % \begin{macrocode}
451 \newcommand*{\DTMdanishdaymonthsep}{\DTMtexorpdfstring{\protect~}{\space}}
452 % \end{macrocode}
453 %\end{macro}
454 %
455 %\begin{macro}{\DTMdanishmonthyearsep}
456 % The separator between the month and year for the text format.
457 % \begin{macrocode}
458 \newcommand*{\DTMdanishmonthyearsep}{\space}
459 % \end{macrocode}
460 %\end{macro}
461 %
462 %\begin{macro}{\DTMdanishdatetimesep}
463 % The separator between the date and time blocks in the full format
464 % (either text or numeric).
465 % \begin{macrocode}
466 \newcommand*{\DTMdanishdatetimesep}{\space}
467 % \end{macrocode}
468 %\end{macro}
469 %
470 %\begin{macro}{\DTMdanishtimezonesep}
471 % The separator between the time and zone blocks in the full format
472 % (either text or numeric).
473 % \begin{macrocode}
474 \newcommand*{\DTMdanishtimezonesep}{\space}
475 % \end{macrocode}
476 %\end{macro}
477 %
478 %\begin{macro}{\DTMdanishdatesep}
479 % The separator for the numeric date format.
480 % \begin{macrocode}
481 \newcommand*{\DTMdanishdatesep}{-}
482 % \end{macrocode}
483 %\end{macro}
484 %
485 %\begin{macro}{\DTMdanishtimesep}
486 % The separator for the numeric time format.
487 % \begin{macrocode}
488 \newcommand*{\DTMdanishtimesep}{:}
489 % \end{macrocode}
490 %\end{macro}
491 %
492 %Provide keys that can be used in \cs{DTMlangsetup} to set these
493 %separators.
494 % \begin{macrocode}
495 \DTMdefkey{danish}{daymonthsep}{\renewcommand*{\DTMdanishdaymonthsep}{#1}}
496 \DTMdefkey{danish}{monthyearsep}{\renewcommand*{\DTMdanishmonthyearsep}{#1}}
497 \DTMdefkey{danish}{datetimesep}{\renewcommand*{\DTMdanishdatetimesep}{#1}}
498 \DTMdefkey{danish}{timezonesep}{\renewcommand*{\DTMdanishtimezonesep}{#1}}
499 \DTMdefkey{danish}{datesep}{\renewcommand*{\DTMdanishdatesep}{#1}}
500 \DTMdefkey{danish}{timesep}{\renewcommand*{\DTMdanishtimesep}{#1}}
501 % \end{macrocode}
502 %
503 % TODO: provide a boolean key to switch between full and abbreviated
504 % formats if appropriate. (I don't know how the date should be
505 % abbreviated.)
506 %
507 % Define a boolean key that determines if the time zone mappings
508 % should be used.
509 % \begin{macrocode}
510 \DTMdefboolkey{danish}{mapzone}[true]{}
511 % \end{macrocode}
512 % The default is to use mappings.
513 % \begin{macrocode}
514 \DTMsetbool{danish}{mapzone}{true}
515 % \end{macrocode}
516 %
517 % Define a boolean key that determines if the day of month should be
518 % displayed.
519 % \begin{macrocode}
520 \DTMdefboolkey{danish}{showdayofmonth}[true]{}
521 % \end{macrocode}
522 % The default is to show the day of month.
523 % \begin{macrocode}
524 \DTMsetbool{danish}{showdayofmonth}{true}
525 % \end{macrocode}
526 %
527 % Define a boolean key that determines if the year should be
528 % displayed.
529 % \begin{macrocode}
530 \DTMdefboolkey{danish}{showyear}[true]{}
531 % \end{macrocode}
532 % The default is to show the year.
533 % \begin{macrocode}
534 \DTMsetbool{danish}{showyear}{true}
535 % \end{macrocode}
536 %
537 % Define the "danish" style. (TODO: implement day of week?)
538 % \begin{macrocode}
539 \DTMnewstyle
540 {danish}% label
541 {% date style
542 \renewcommand*\DTMdisplaydate[4]{%
543 \DTMifbool{danish}{showdayofmonth}
544 {\DTMdanishordinal{##3}\DTMdanishdaymonthsep}%
545 {}%
546 \DTMdanishmonthname{##2}%
547 \DTMifbool{danish}{showyear}%
548 {%
549 \DTMdanishmonthyearsep
550 \number##1
551 }%
552 {}%
553 }%
554 \renewcommand*\DTMDisplaydate[4]{%
555 \DTMifbool{danish}{showdayofmonth}
556 {%
557 \DTMdanishordinal{##3}\DTMdanishdaymonthsep
558 \DTMdanishmonthname{##2}%
559 }%
560 {%
561 \DTMdanishMonthname{##2}%
562 }%
563 \DTMifbool{danish}{showyear}%
564 {%
565 \DTMdanishmonthyearsep
566 \number##1
567 }%
568 {}%
569 }%
570 }%
571 {% time style (use default)
572 \DTMsettimestyle{default}%
573 }%
574 {% zone style
575 \DTMresetzones
576 \DTMdanishzonemaps
577 \renewcommand*{\DTMdisplayzone}[2]{%
578 \DTMifbool{danish}{mapzone}%
579 {\DTMusezonemapordefault{##1}{##2}}%
580 {%
581 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
582 \ifDTMshowzoneminutes\DTMdanishtimesep\DTMtwodigits{##2}\fi
583 }%
584 }%
585 }%
586 {% full style
587 \renewcommand*{\DTMdisplay}[9]{%
588 \ifDTMshowdate
589 \DTMdisplaydate{##1}{##2}{##3}{##4}%
590 \DTMdanishdatetimesep
591 \fi
592 \DTMdisplaytime{##5}{##6}{##7}%
593 \ifDTMshowzone
594 \DTMdanishtimezonesep
595 \DTMdisplayzone{##8}{##9}%
596 \fi
597 }%
598 \renewcommand*{\DTMDisplay}[9]{%
599 \ifDTMshowdate
600 \DTMDisplaydate{##1}{##2}{##3}{##4}%
601 \DTMdanishdatetimesep
602 \fi
603 \DTMdisplaytime{##5}{##6}{##7}%
604 \ifDTMshowzone
605 \DTMdanishtimezonesep
606 \DTMdisplayzone{##8}{##9}%
607 \fi
608 }%
609 }%
610 % \end{macrocode}
611 %
612 % Define numeric style.
613 % \begin{macrocode}
614 \DTMnewstyle
615 {danish-numeric}% label
616 {% date style
617 \renewcommand*\DTMdisplaydate[4]{%
618 \DTMifbool{danish}{showdayofmonth}%
619 {%
620 \number##3 % space intended
621 \DTMdanishdatesep
622 }%
623 {}%
624 \number##2 % space intended
625 \DTMifbool{danish}{showyear}%
626 {%
627 \DTMdanishdatesep
628 \number##1 % space intended
629 }%
630 {}%
631 }%
632 \renewcommand*{\DTMDisplaydate}[4]{\DTMdisplaydate{##1}{##2}{##3}{##4}}%
633 }%
634 {% time style
635 \renewcommand*\DTMdisplaytime[3]{%
636 \number##1
637 \DTMdanishtimesep\DTMtwodigits{##2}%
638 \ifDTMshowseconds\DTMdanishtimesep\DTMtwodigits{##3}\fi
639 }%
640 }%
641 {% zone style
642 \DTMresetzones
643 \DTMdanishzonemaps
644 \renewcommand*{\DTMdisplayzone}[2]{%
645 \DTMifbool{danish}{mapzone}%
646 {\DTMusezonemapordefault{##1}{##2}}%
647 {%
648 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
649 \ifDTMshowzoneminutes\DTMdanishtimesep\DTMtwodigits{##2}\fi
650 }%
651 }%
652 }%
653 {% full style
654 \renewcommand*{\DTMdisplay}[9]{%
655 \ifDTMshowdate
656 \DTMdisplaydate{##1}{##2}{##3}{##4}%
657 \DTMdanishdatetimesep
658 \fi
659 \DTMdisplaytime{##5}{##6}{##7}%
660 \ifDTMshowzone
661 \DTMdanishtimezonesep
662 \DTMdisplayzone{##8}{##9}%
663 \fi
664 }%
665 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
666 }
667 % \end{macrocode}
668 %
669 %\begin{macro}{\DTMdanishzonemaps}
670 % The time zone mappings are set through this command, which can be
671 % redefined if extra mappings are required or mappings need to be
672 % removed.
673 % \begin{macrocode}
674 \newcommand*{\DTMdanishzonemaps}{%
675 \DTMdefzonemap{01}{00}{CET}%
676 \DTMdefzonemap{02}{00}{CEST}%
677 }
678 % \end{macrocode}
679 %\end{macro}
680
681 % Switch style according to the \opt{useregional} setting.
682 % \begin{macrocode}
683 \DTMifcaseregional
684 {}% do nothing
685 {\DTMsetstyle{danish}}
686 {\DTMsetstyle{danish-numeric}}
687 % \end{macrocode}
688 %
689 % Redefine \cs{datedanish} (or \cs{date}\meta{dialect}) to prevent
690 % \sty{babel} from resetting \cs{today}. (For this to work,
691 % \sty{babel} must already have been loaded if it's required.)
692 %\changes{1.1}{2018-03-19}{removed spurious space}
693 % \begin{macrocode}
694 \ifcsundef{date\CurrentTrackedDialect}
695 {%
696 \ifundef\datedanish
697 {% do nothing
698 }%
699 {%
700 \def\datedanish{%
701 \DTMifcaseregional
702 {}% do nothing
703 {\DTMsetstyle{danish}}%
704 {\DTMsetstyle{danish-numeric}}%
705 }%
706 }%
707 }%
708 {%
709 \csdef{date\CurrentTrackedDialect}{%
710 \DTMifcaseregional
711 {}% do nothing
712 {\DTMsetstyle{danish}}%
713 {\DTMsetstyle{danish-numeric}}%
714 }%
715 }%
716 % \end{macrocode}
717 %\iffalse
718 % \begin{macrocode}
719 %</datetime2-danish.ldf>
720 % \end{macrocode}
721 %\fi
722 %\Finale
723 \endinput