Debian Codegraph @

texmf-dist/source/latex/datetime2-hebrew/datetime2-hebrew.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[utf8]{inputenc}
32 \usepackage[T1]{fontenc}
33 \usepackage[colorlinks,
34 bookmarks,
35 hyperindex=false,
36 pdfauthor={Nicola L.C. Talbot},
37 pdftitle={datetime2.sty Hebrew Module}]{hyperref}
38
39 \CheckSum{162}
40
41 \renewcommand*{\usage}[1]{\hyperpage{#1}}
42 \renewcommand*{\main}[1]{\hyperpage{#1}}
43 \IndexPrologue{\section*{\indexname}\markboth{\indexname}{\indexname}}
44 \setcounter{IndexColumns}{2}
45
46 \newcommand*{\sty}[1]{\textsf{#1}}
47 \newcommand*{\opt}[1]{\texttt{#1}\index{#1=\texttt{#1}|main}}
48
49 \RecordChanges
50 \PageIndex
51 \CodelineNumbered
52
53 \begin{document}
54 \DocInput{datetime2-hebrew.dtx}
55 \end{document}
56 %</driver>
57 %\fi
58 %
59 %\MakeShortVerb{"}
60 %
61 %\title{Hebrew Module for datetime2 Package}
62 %\author{Nicola L. C. Talbot (inactive)}
63 %\date{2010-04-18 (v1.1)}
64 %\maketitle
65 %
66 %This module is currently unmaintained and may be subject to change.
67 %If you want to volunteer to take over maintanance, contact me at
68 %\url{http://www.dickimaw-books.com/contact.html}
69 %
70 %\begin{abstract}
71 %This is the Hebrew language module for the \sty{datetime2}
72 %package. If you want to use the settings in this module you must
73 %install it in addition to installing \sty{datetime2}. If you use
74 %\sty{babel} or \sty{polyglossia}, you will need this module to
75 %prevent them from redefining \cs{today}. The \sty{datetime2}
76 % \opt{useregional} setting must be set to "text" or "numeric"
77 % for the language styles to be set.
78 % Alternatively, you can set the style in the document using
79 % \cs{DTMsetstyle}, but this may be changed by \cs{date}\meta{language}
80 % depending on the value of the \opt{useregional} setting.
81 %\end{abstract}
82 %
83 %The date style simply uses either \sty{babel}'s \cs{hebdate}
84 %or \sty{polyglossia}'s \cs{hebrewdate} so the date style isn't
85 %expandable.
86 %
87 %I don't know if these settings are correct as I can't speak Hebrew.
88 %In particular, I don't know if the "hebrew" 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-hebrew.ins} where Name
98 %is the name of the maintainer(s) and replace
99 %the `inactive' status to `maintained'.
100 %
101 %
102 %\StopEventually{%
103 %\clearpage
104 %\phantomsection
105 %\addcontentsline{toc}{section}{Change History}%
106 %\PrintChanges
107 %\addcontentsline{toc}{section}{\indexname}%
108 %\PrintIndex}
109 %\section{The Code}
110 % There is currently only one ".ldf" file.
111 %
112 %\subsection{Main Hebrew Module (\texttt{datetime2-hebrew.ldf})}
113 %\changes{1.0}{2015-03-30}{Initial release}
114 %
115 %\iffalse
116 % \begin{macrocode}
117 %<*datetime2-hebrew.ldf>
118 % \end{macrocode}
119 %\fi
120 %
121 % Identify Module
122 % \begin{macrocode}
123 \ProvidesDateTimeModule{hebrew}[2018/04/18 v1.1]
124 % \end{macrocode}
125 % The date style uses \cs{hebrewdate} or \cs{hebdate}, depending on
126 % which is defined. This needs to be robust, which means the date
127 % can't be expanded with this style. This should be fixed if at all
128 % possible. (I don't know how.)
129 %\begin{macro}{\DTMhebrewdate}
130 % \begin{macrocode}
131 \ifdef\hebrewdate
132 {%
133 \newrobustcmd*\DTMhebrewdate[3]{\hebrewdate{#3}{#2}{#1}}%
134 }%
135 {%
136 \ifdef\hebdate
137 {%
138 \newrobustcmd*\DTMhebrewdate[3]{\hebdate{#3}{#2}{#1}}%
139 }%
140 {%
141 \newcommand*\DTMhebrewdate[3]{#3-#2-#1}%
142 \PackageWarning{datetime2-hebrew}{Neither
143 \string\hebrewdate\space nor \string\hebdate\space defined}{}%
144 }%
145 }%
146 % \end{macrocode}
147 %\end{macro}
148 %For some reason \cs{hebrewdate} doesn't work with \cs{datetime2}'s
149 %definition of \cs{today} so it needs to be changed.
150 %\begin{macro}{\today}
151 % \begin{macrocode}
152 \renewcommand*{\today}{\DTMdisplaydate{\year}{\month}{\day}{-1}}
153 % \end{macrocode}
154 %\end{macro}
155 %\begin{macro}{\Today}
156 % \begin{macrocode}
157 \renewcommand*{\Today}{\DTMDisplaydate{\year}{\month}{\day}{-1}}
158 % \end{macrocode}
159 %\end{macro}
160 %
161 %The full style will probably need to check for RL or LR.
162 %\begin{macro}{\DTMhebrewdatetimesep}
163 % The separator between the date and time blocks in the full format
164 % (either text or numeric).
165 % \begin{macrocode}
166 \newcommand*{\DTMhebrewdatetimesep}{\space}
167 % \end{macrocode}
168 %\end{macro}
169 %
170 %\begin{macro}{\DTMhebrewtimezonesep}
171 % The separator between the time and zone blocks in the full format
172 % (either text or numeric).
173 % \begin{macrocode}
174 \newcommand*{\DTMhebrewtimezonesep}{\space}
175 % \end{macrocode}
176 %\end{macro}
177 %
178 %\begin{macro}{\DTMhebrewdatesep}
179 % The separator for the numeric date format.
180 % \begin{macrocode}
181 \newcommand*{\DTMhebrewdatesep}{.}
182 % \end{macrocode}
183 %\end{macro}
184 %
185 %\begin{macro}{\DTMhebrewtimesep}
186 % The separator for the numeric time format.
187 % \begin{macrocode}
188 \newcommand*{\DTMhebrewtimesep}{:}
189 % \end{macrocode}
190 %\end{macro}
191 %
192 %Provide keys that can be used in \cs{DTMlangsetup} to set these
193 %separators.
194 % \begin{macrocode}
195 \DTMdefkey{hebrew}{datetimesep}{\renewcommand*{\DTMhebrewdatetimesep}{#1}}
196 \DTMdefkey{hebrew}{timezonesep}{\renewcommand*{\DTMhebrewtimezonesep}{#1}}
197 \DTMdefkey{hebrew}{datesep}{\renewcommand*{\DTMhebrewdatesep}{#1}}
198 \DTMdefkey{hebrew}{timesep}{\renewcommand*{\DTMhebrewtimesep}{#1}}
199 % \end{macrocode}
200 %
201 % Define a boolean key that determines if the time zone mappings
202 % should be used.
203 % \begin{macrocode}
204 \DTMdefboolkey{hebrew}{mapzone}[true]{}
205 % \end{macrocode}
206 % The default is to use mappings.
207 % \begin{macrocode}
208 \DTMsetbool{hebrew}{mapzone}{true}
209 % \end{macrocode}
210 %
211 % Define the "hebrew" style.
212 % \begin{macrocode}
213 \DTMnewstyle
214 {hebrew}% label
215 {% date style
216 \renewcommand*\DTMdisplaydate[4]{%
217 \DTMtexorpdfstring{\DTMhebrewdate{##1}{##2}{##3}}{##3-##2-##1}%
218 }%
219 \renewcommand*\DTMDisplaydate{\DTMdisplaydate}%
220 }%
221 {% time style (use default)
222 \DTMsettimestyle{default}%
223 }%
224 {% zone style
225 \DTMresetzones
226 \DTMhebrewzonemaps
227 \renewcommand*{\DTMdisplayzone}[2]{%
228 \DTMifbool{hebrew}{mapzone}%
229 {\DTMusezonemapordefault{##1}{##2}}%
230 {%
231 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
232 \ifDTMshowzoneminutes\DTMhebrewtimesep\DTMtwodigits{##2}\fi
233 }%
234 }%
235 }%
236 {% full style
237 \renewcommand*{\DTMdisplay}[9]{%
238 \ifDTMshowdate
239 \DTMdisplaydate{##1}{##2}{##3}{##4}%
240 \DTMhebrewdatetimesep
241 \fi
242 \DTMdisplaytime{##5}{##6}{##7}%
243 \ifDTMshowzone
244 \DTMhebrewtimezonesep
245 \DTMdisplayzone{##8}{##9}%
246 \fi
247 }%
248 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
249 }%
250 % \end{macrocode}
251 %
252 % Define numeric style.
253 % \begin{macrocode}
254 \DTMnewstyle
255 {hebrew-numeric}% label
256 {% date style
257 \renewcommand*\DTMdisplaydate[4]{%
258 \DTMifbool{hebrew}{showdayofmonth}%
259 {%
260 \number##3 % space intended
261 \DTMhebrewdatesep
262 }%
263 {}%
264 \number##2 % space intended
265 \DTMifbool{hebrew}{showyear}%
266 {%
267 \DTMhebrewdatesep
268 \number##1 % space intended
269 }%
270 {}%
271 }%
272 \renewcommand*\DTMDisplaydate{\DTMdisplaydate}%
273 }%
274 {% time style
275 \renewcommand*\DTMdisplaytime[3]{%
276 \number##1
277 \DTMhebrewtimesep\DTMtwodigits{##2}%
278 \ifDTMshowseconds\DTMhebrewtimesep\DTMtwodigits{##3}\fi
279 }%
280 }%
281 {% zone style
282 \DTMresetzones
283 \DTMhebrewzonemaps
284 \renewcommand*{\DTMdisplayzone}[2]{%
285 \DTMifbool{hebrew}{mapzone}%
286 {\DTMusezonemapordefault{##1}{##2}}%
287 {%
288 \ifnum##1<0\else+\fi\DTMtwodigits{##1}%
289 \ifDTMshowzoneminutes\DTMhebrewtimesep\DTMtwodigits{##2}\fi
290 }%
291 }%
292 }%
293 {% full style
294 \renewcommand*{\DTMdisplay}[9]{%
295 \ifDTMshowdate
296 \DTMdisplaydate{##1}{##2}{##3}{##4}%
297 \DTMhebrewdatetimesep
298 \fi
299 \DTMdisplaytime{##5}{##6}{##7}%
300 \ifDTMshowzone
301 \DTMhebrewtimezonesep
302 \DTMdisplayzone{##8}{##9}%
303 \fi
304 }%
305 \renewcommand*{\DTMDisplay}{\DTMdisplay}%
306 }
307 % \end{macrocode}
308 %
309 %\begin{macro}{\DTMhebrewzonemaps}
310 % The time zone mappings are set through this command, which can be
311 % redefined if extra mappings are required or mappings need to be
312 % removed. There are currently no mappings.
313 % \begin{macrocode}
314 \newcommand*{\DTMhebrewzonemaps}{%
315 }
316 % \end{macrocode}
317 %\end{macro}
318
319 % Switch style according to the \opt{useregional} setting.
320 % \begin{macrocode}
321 \DTMifcaseregional
322 {}% do nothing
323 {\DTMsetstyle{hebrew}}
324 {\DTMsetstyle{hebrew-numeric}}
325 % \end{macrocode}
326 %
327 % Redefine \cs{datehebrew} (or \cs{date}\meta{dialect}) to prevent
328 % \sty{babel} from resetting \cs{today}. (For this to work,
329 % \sty{babel} must already have been loaded if it's required.)
330 %\changes{1.1}{2018-04-18}{removed spurious space}
331 % \begin{macrocode}
332 \ifcsundef{date\CurrentTrackedDialect}
333 {%
334 \ifundef\datehebrew
335 {% do nothing
336 }%
337 {%
338 \def\datehebrew{%
339 \DTMifcaseregional
340 {}% do nothing
341 {\DTMsetstyle{hebrew}}%
342 {\DTMsetstyle{hebrew-numeric}}%
343 }%
344 }%
345 }%
346 {%
347 \csdef{date\CurrentTrackedDialect}{%
348 \DTMifcaseregional
349 {}% do nothing
350 {\DTMsetstyle{hebrew}}%
351 {\DTMsetstyle{hebrew-numeric}}%
352 }%
353 }%
354 % \end{macrocode}
355 %\iffalse
356 % \begin{macrocode}
357 %</datetime2-hebrew.ldf>
358 % \end{macrocode}
359 %\fi
360 %\Finale
361 \endinput