Debian Codegraph @

texmf-dist/source/latex/datetime2-welsh/datetime2-welsh.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-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 Welsh Module}]{hyperref}
38
39
40 \CheckSum{261}
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-welsh.dtx}
56 \end{document}
57 %</driver>
58 %\fi
59 %
60 %\MakeShortVerb{"}
61 %
62 %\title{Welsh Module for datetime2 Package}
63 %\author{Nicola L. C. Talbot (inactive)}
64 %\date{2019-10-28 (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 Welsh 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-welsh}'s \cs{today}.
85 %
86 %I don't know if these settings are correct as I can't speak Welsh.
87 %In particular, I don't know if the "welsh" 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-welsh.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 "cy-GB"\slash"cy-GB-numeric" and
102 %"cy-AR"\slash"cy-AR-numeric". This style currently doesn't check the
103 %\opt{showdow} setting.
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-welsh-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-26}{Initial release}
123 % Identify module
124 % \begin{macrocode}
125 \ProvidesDateTimeModule{welsh-utf8}[2019/10/28 v1.1]
126 % \end{macrocode}
127 %\begin{macro}{\DTMwelshordinal}
128 % \begin{macrocode}
129 \newcommand*{\DTMwelshordinal}[1]{%
130 \number#1 % space intended
131 \ifnum#1=1 % space intended
132 \DTMwelshfmtordinal{aƱ}%
133 \fi
134 }
135 % \end{macrocode}
136 %\end{macro}
137 %
138 %\begin{macro}{\DTMwelshfmtordinal}
139 % \begin{macrocode}
140 \newcommand*{\DTMwelshfmtordinal}[1]{%
141 \DTMtexorpdfstring{\protect\textsuperscript{#1}}{#1}%
142 }
143 % \end{macrocode}
144 %\end{macro}
145 %
146 %\begin{macro}{\DTMwelshmonthname}
147 % Welsh month names.
148 % \begin{macrocode}
149 \newcommand*{\DTMwelshmonthname}[1]{%
150 \ifcase#1
151 \or
152 Ionawr%
153 \or
154 Chwefror%
155 \or
156 Mawrth%
157 \or
158 Ebrill%
159 \or
160 Mai%
161 \or
162 Mehefin%
163 \or
164 Gorffennaf%
165 \or
166 Awst%
167 \or
168 Medi%
169 \or
170 Hydref%
171 \or
172 Tachwedd%
173 \or
174 Rhagfyr%
175 \fi
176 }
177 % \end{macrocode}
178 %\end{macro}
179 %
180 %If abbreviated dates are supported, short month names should be
181 %likewise provided.
182 %
183 %\iffalse
184 % \begin{macrocode}
185 %</datetime2-welsh-utf8.ldf>
186 % \end{macrocode}
187 %\fi
188 %\iffalse
189 % \begin{macrocode}
190 %<*datetime2-welsh-ascii.ldf>
191 % \end{macrocode}
192 %\fi
193 %\subsection{ASCII}
194 %This file contains the settings that use \LaTeX\ commands for
195 %non-ASCII characters. This should be input if neither XeLaTeX nor
196 %LuaLaTeX are used. Even if the user has loaded \sty{inputenc} with
197 %"utf8", this file should still be used not the
198 %\texttt{datetime2-welsh-utf8.ldf} file as the non-ASCII
199 %characters are made active in that situation and would need
200 %protecting against expansion.
201 %\changes{1.0}{2015-03-26}{Initial release}
202 % Identify module
203 % \begin{macrocode}
204 \ProvidesDateTimeModule{welsh-ascii}[2019/10/28 v1.1]
205 % \end{macrocode}
206 %
207 %If abbreviated dates are supported, short month names should be
208 %likewise provided.
209 %\begin{macro}{\DTMwelshordinal}
210 % \begin{macrocode}
211 \newcommand*{\DTMwelshordinal}[1]{%
212 \number#1 % space intended
213 \ifnum#1=1 % space intended
214 \DTMwelshfmtordsuffix{a\protect\~{n}}%
215 \fi
216 }
217 % \end{macrocode}
218 %\end{macro}
219 %
220 %\begin{macro}{\DTMwelshfmtordsuffix}
221 % \begin{macrocode}
222 \newcommand*{\DTMwelshfmtordsuffix}[1]{%
223 \DTMtexorpdfstring{\protect\textsuperscript{#1}}{#1}%
224 }
225 % \end{macrocode}
226 %\end{macro}
227 %
228 %\begin{macro}{\DTMwelshmonthname}
229 % Welsh month names.
230 % \begin{macrocode}
231 \newcommand*{\DTMwelshmonthname}[1]{%
232 \ifcase#1
233 \or
234 Ionawr%
235 \or
236 Chwefror%
237 \or
238 Mawrth%
239 \or
240 Ebrill%
241 \or
242 Mai%
243 \or
244 Mehefin%
245 \or
246 Gorffennaf%
247 \or
248 Awst%
249 \or
250 Medi%
251 \or
252 Hydref%
253 \or
254 Tachwedd%
255 \or
256 Rhagfyr%
257 \fi
258 }
259 % \end{macrocode}
260 %\end{macro}
261 %
262 %\iffalse
263 % \begin{macrocode}
264 %</datetime2-welsh-ascii.ldf>
265 % \end{macrocode}
266 %\fi
267 %
268 %\subsection{Main Welsh Module (\texttt{datetime2-welsh.ldf})}
269 %\changes{1.0}{2015-03-26}{Initial release}
270 %
271 %\iffalse
272 % \begin{macrocode}
273 %<*datetime2-welsh.ldf>
274 % \end{macrocode}
275 %\fi
276 %
277 % Identify Module
278 % \begin{macrocode}
279 \ProvidesDateTimeModule{welsh}[2019/10/28 v1.1]
280 % \end{macrocode}
281 % Need to find out if XeTeX or LuaTeX are being used.
282 % \begin{macrocode}
283 \RequirePackage{ifxetex,ifluatex}
284 % \end{macrocode}
285 % XeTeX and LuaTeX natively support UTF-8, so load
286 % \texttt{welsh-utf8} if either of those engines are used
287 % otherwise load \texttt{welsh-ascii}.
288 % \begin{macrocode}
289 \ifxetex
290 \RequireDateTimeModule{welsh-utf8}
291 \else
292 \ifluatex
293 \RequireDateTimeModule{welsh-utf8}
294 \else
295 \RequireDateTimeModule{welsh-ascii}
296 \fi
297 \fi
298 % \end{macrocode}
299 %
300 % Define the \texttt{welsh} style.
301 % The time style is the same as the "default" style
302 % provided by \sty{datetime2}. This may need correcting. For
303 % example, if a 12 hour style similar to the "englishampm" (from the
304 % "english-base" module) is required.
305 %
306 % Allow the user a way of configuring the "welsh" and
307 % "welsh-numeric" styles. This doesn't use the package wide
308 % separators such as
309 % \cs{dtm@datetimesep} in case other date formats are also required.
310 %\begin{macro}{\DTMwelshdaymonthsep}
311 % The separator between the day and month for the text format.
312 % \begin{macrocode}
313 \newcommand*{\DTMwelshdaymonthsep}{\space}
314 % \end{macrocode}
315 %\end{macro}
316 %
317 %\begin{macro}{\DTMwelshmonthyearsep}
318 % The separator between the month and year for the text format.
319 % \begin{macrocode}
320 \newcommand*{\DTMwelshmonthyearsep}{\space}
321 % \end{macrocode}
322 %\end{macro}
323 %
324 %\begin{macro}{\DTMwelshdatetimesep}
325 % The separator between the date and time blocks in the full format
326 % (either text or numeric).
327 % \begin{macrocode}
328 \newcommand*{\DTMwelshdatetimesep}{\space}
329 % \end{macrocode}
330 %\end{macro}
331 %
332 %\begin{macro}{\DTMwelshtimezonesep}
333 % The separator between the time and zone blocks in the full format
334 % (either text or numeric).
335 % \begin{macrocode}
336 \newcommand*{\DTMwelshtimezonesep}{\space}
337 % \end{macrocode}
338 %\end{macro}
339 %
340 %\begin{macro}{\DTMwelshdatesep}
341 % The separator for the numeric date format.
342 % \begin{macrocode}
343 \newcommand*{\DTMwelshdatesep}{/}
344 % \end{macrocode}
345 %\end{macro}
346 %
347 %\begin{macro}{\DTMwelshtimesep}
348 % The separator for the numeric time format.
349 % \begin{macrocode}
350 \newcommand*{\DTMwelshtimesep}{:}
351 % \end{macrocode}
352 %\end{macro}
353 %
354 %Provide keys that can be used in \cs{DTMlangsetup} to set these
355 %separators.
356 % \begin{macrocode}
357 \DTMdefkey{welsh}{daymonthsep}{\renewcommand*{\DTMwelshdaymonthsep}{#1}}
358 \DTMdefkey{welsh}{monthyearsep}{\renewcommand*{\DTMwelshmonthyearsep}{#1}}
359 \DTMdefkey{welsh}{datetimesep}{\renewcommand*{\DTMwelshdatetimesep}{#1}}
360 \DTMdefkey{welsh}{timezonesep}{\renewcommand*{\DTMwelshtimezonesep}{#1}}
361 \DTMdefkey{welsh}{datesep}{\renewcommand*{\DTMwelshdatesep}{#1}}
362 \DTMdefkey{welsh}{timesep}{\renewcommand*{\DTMwelshtimesep}{#1}}
363 % \end{macrocode}
364 %
365 % Define a setting to change the ordinal suffix style.
366 %\changes{1.1}{2019-10-28}{renamed scratch variables}
367 % \begin{macrocode}
368 \DTMdefchoicekey{welsh}{ord}[\@dtm@val\@dtm@nr]{level,raise,omit,sc}{%
369 \ifcase\@dtm@nr\relax
370 \renewcommand*{\DTMwelshfmtordsuffix}[1]{##1}%
371 \or
372 \renewcommand*{\DTMwelshfmtordsuffix}[1]{%
373 \DTMtexorpdfstring{\protect\textsuperscript{##1}}{##1}}%
374 \or
375 \renewcommand*{\DTMwelshfmtordsuffix}[1]{}%
376 \or
377 \renewcommand*{\DTMwelshfmtordsuffix}[1]{%
378 \DTMtexorpdfstring{\protect\textsc{##1}}{##1}}%
379 \fi
380 }
381 % \end{macrocode}
382 %
383 % TODO: provide a boolean key to switch between full and abbreviated
384 % formats if appropriate. (I don't know how the date should be
385 % abbreviated.)
386 %
387 % Define a boolean key that determines if the time zone mappings
388 % should be used.
389 % \begin{macrocode}
390 \DTMdefboolkey{welsh}{mapzone}[true]{}
391 % \end{macrocode}
392 % The default is to use mappings.
393 % \begin{macrocode}
394 \DTMsetbool{welsh}{mapzone}{true}
395 % \end{macrocode}
396 %
397 % Define a boolean key that determines if the day of month should be
398 % displayed.
399 % \begin{macrocode}
400 \DTMdefboolkey{welsh}{showdayofmonth}[true]{}
401 % \end{macrocode}
402 % The default is to show the day of month.
403 % \begin{macrocode}
404 \DTMsetbool{welsh}{showdayofmonth}{true}
405 % \end{macrocode}
406 %
407 % Define a boolean key that determines if the year should be
408 % displayed.
409 % \begin{macrocode}
410 \DTMdefboolkey{welsh}{showyear}[true]{}
411 % \end{macrocode}
412 % The default is to show the year.
413 % \begin{macrocode}
414 \DTMsetbool{welsh}{showyear}{true}
415 % \end{macrocode}
416 %
417 % Define the "welsh" style. (TODO: implement day of week?)
418 % \begin{macrocode}
419 \DTMnewstyle
420 {welsh}% label
421 {% date style
422 \renewcommand*\DTMdisplaydate[4]{%
423 \DTMifbool{welsh}{showdayofmonth}
424 {\DTMwelshordinal{##3}\DTMwelshdaymonthsep}%
425 {}%
426 \DTMwelshmonthname{##2}%
427 \DTMifbool{welsh}{showyear}%
428 {%
429 \DTMwelshmonthyearsep
430 \number##1 % space intended
431 }%
432 {}%
433 }%
434 \renewcommand*\DTMDisplaydate[4]{%
435 \DTMifbool{welsh}{showdayofmonth}
436 {%
437 \DTMwelshordinal{##3}\DTMwelshdaymonthsep
438 \DTMwelshMonthname{##2}%
439 }%
440 {\DTMwelshMonthname{##2}}%
441 \DTMifbool{welsh}{showyear}%
442 {%
443 \DTMwelshmonthyearsep
444 \number##1 % space intended
445 }%
446 {}%
447 }%
448 }%
449 {% time style (use default)
450 \DTMsettimestyle{default}%
451 }%
452 {% zone style
453 \DTMresetzones
454 \DTMwelshzonemaps
455 \renewcommand*{\DTMdisplayzone}[2]{%
456 \DTMifbool{welsh}{mapzone}%
457 {\DTMusezonemapordefault{##1}{##2}}%
458 {%
459 \ifnum##1<0 \else+\fi\DTMtwodigits{##1}%
460 \ifDTMshowzoneminutes\DTMwelshtimesep\DTMtwodigits{##2}\fi
461 }%
462 }%
463 }%
464 {% full style
465 \renewcommand*{\DTMdisplay}[9]{%
466 \ifDTMshowdate
467 \DTMdisplaydate{##1}{##2}{##3}{##4}%
468 \DTMwelshdatetimesep
469 \fi
470 \DTMdisplaytime{##5}{##6}{##7}%
471 \ifDTMshowzone
472 \DTMwelshtimezonesep
473 \DTMdisplayzone{##8}{##9}%
474 \fi
475 }%
476 \renewcommand*{\DTMDisplay}[9]{%
477 \ifDTMshowdate
478 \DTMDisplaydate{##1}{##2}{##3}{##4}%
479 \DTMwelshdatetimesep
480 \fi
481 \DTMdisplaytime{##5}{##6}{##7}%
482 \ifDTMshowzone
483 \DTMwelshtimezonesep
484 \DTMdisplayzone{##8}{##9}%
485 \fi
486 }%
487 }%
488 % \end{macrocode}
489 %
490 % Define numeric style.
491 % \begin{macrocode}
492 \DTMnewstyle
493 {welsh-numeric}% label
494 {% date style
495 \renewcommand*\DTMdisplaydate[4]{%
496 \DTMifbool{welsh}{showdayofmonth}%
497 {%
498 \number##3 % space intended
499 \DTMwelshdatesep
500 }%
501 {}%
502 \number##2 % space intended
503 \DTMifbool{welsh}{showyear}%
504 {%
505 \DTMwelshdatesep
506 \number##1 % space intended
507 }%
508 {}%
509 }%
510 \renewcommand*{\DTMDisplaydate}[4]{\DTMdisplaydate{##1}{##2}{##3}{##4}}%
511 }%
512 {% time style
513 \renewcommand*\DTMdisplaytime[3]{%
514 \number##1
515 \DTMwelshtimesep\DTMtwodigits{##2}%
516 \ifDTMshowseconds\DTMwelshtimesep\DTMtwodigits{##3}\fi
517 }%
518 }%
519 {% zone style
520 \DTMresetzones
521 \DTMwelshzonemaps
522 \renewcommand*{\DTMdisplayzone}[2]{%
523 \DTMifbool{welsh}{mapzone}%
524 {\DTMusezonemapordefault{##1}{##2}}%
525 {%
526 \ifnum##1<0 \else+\fi\DTMtwodigits{##1}%
527 \ifDTMshowzoneminutes\DTMwelshtimesep\DTMtwodigits{##2}\fi
528 }%
529 }%
530 }%
531 {% full style
532 \renewcommand*{\DTMdisplay}[9]{%
533 \ifDTMshowdate
534 \DTMdisplaydate{##1}{##2}{##3}{##4}%
535 \DTMwelshdatetimesep
536 \fi
537 \DTMdisplaytime{##5}{##6}{##7}%
538 \ifDTMshowzone
539 \DTMwelshtimezonesep
540 \DTMdisplayzone{##8}{##9}%
541 \fi
542 }%
543 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
544 }
545 % \end{macrocode}
546 %
547 %\begin{macro}{\DTMwelshzonemaps}
548 % The time zone mappings are set through this command, which can be
549 % redefined if extra mappings are required or mappings need to be
550 % removed.
551 % \begin{macrocode}
552 \newcommand*{\DTMwelshzonemaps}{%
553 \DTMdefzonemap{00}{00}{GMT}%
554 \DTMdefzonemap{01}{00}{BST}%
555 }
556 % \end{macrocode}
557 %\end{macro}
558
559 % Switch style according to the \opt{useregional} setting.
560 % \begin{macrocode}
561 \DTMifcaseregional
562 {}% do nothing
563 {\DTMsetstyle{welsh}}
564 {\DTMsetstyle{welsh-numeric}}
565 % \end{macrocode}
566 %
567 % Redefine \cs{datewelsh} (or \cs{date}\meta{dialect}) to prevent
568 % \sty{babel} from resetting \cs{today}. (For this to work,
569 % \sty{babel} must already have been loaded if it's required.)
570 %\changes{1.1}{2019-10-28}{removed unwanted space}
571 % \begin{macrocode}
572 \ifcsundef{date\CurrentTrackedDialect}
573 {%
574 \ifundef\datewelsh
575 {% do nothing
576 }%
577 {%
578 \def\datewelsh{%
579 \DTMifcaseregional
580 {}% do nothing
581 {\DTMsetstyle{welsh}}%
582 {\DTMsetstyle{welsh-numeric}}%
583 }%
584 }%
585 }%
586 {%
587 \csdef{date\CurrentTrackedDialect}{%
588 \DTMifcaseregional
589 {}% do nothing
590 {\DTMsetstyle{welsh}}%
591 {\DTMsetstyle{welsh-numeric}}%
592 }%
593 }%
594 % \end{macrocode}
595 %\iffalse
596 % \begin{macrocode}
597 %</datetime2-welsh.ldf>
598 % \end{macrocode}
599 %\fi
600 %\Finale
601 \endinput