Debian Codegraph @

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