Debian Codegraph @

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