| 1 |
% \iffalse |
| 2 |
% +AMDG This document was begun on 1 May 1202, the |
| 3 |
% feast of St. Joseph the Worker, and it |
| 4 |
% is humbly dedicated to him and to the Immaculate Heart of |
| 5 |
% Mary for their prayers, and to the Sacred Heart of Jesus |
| 6 |
% for His mercy. |
| 7 |
% |
| 8 |
% This document is copyright 2018 by Donald P. Goodman, and is |
| 9 |
% released publicly under the LaTeX Project Public License. The |
| 10 |
% distribution and modification of this work is constrained by the |
| 11 |
% conditions of that license. See |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% for the text of the license. This document is released |
| 14 |
% under version 1.3(c) of that license, and this work may be distributed |
| 15 |
% or modified under the terms of that license or, at your option, any |
| 16 |
% later version. |
| 17 |
% |
| 18 |
% This work has the LPPL maintenance status 'maintained'. |
| 19 |
% |
| 20 |
% The Current Maintainer of this work is Donald P. Goodman |
| 21 |
% ([email protected]). |
| 22 |
% |
| 23 |
% This work consists of texdate.dtx, texdate.ins, and |
| 24 |
% derived files texdate.sty and texdate.pdf. |
| 25 |
% \fi |
| 26 |
|
| 27 |
% \iffalse |
| 28 |
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] |
| 29 |
%<package>\ProvidesPackage{texdate}[2018/12/08 v2.0 Print and manipulate dates in plain TeX] |
| 30 |
%<*driver> |
| 31 |
\documentclass{ltxdoc} |
| 32 |
|
| 33 |
\usepackage{doc} |
| 34 |
\usepackage{modulus} |
| 35 |
\usepackage{multicol} |
| 36 |
\usepackage{texdate} |
| 37 |
\usepackage{fancyvrb} |
| 38 |
\usepackage{fvrb-ex} |
| 39 |
\usepackage{booktabs} |
| 40 |
\usepackage[typeone]{dozenal} |
| 41 |
\def\x{\noexpand{\TextOrMath{\protect\doz{{X}}}{\doz@X}}}% |
| 42 |
\def\e{\noexpand{\TextOrMath{\protect\doz{{E}}}{\doz@E}}}% |
| 43 |
\usepackage{longtable} |
| 44 |
\usepackage{xellipsis} |
| 45 |
|
| 46 |
\begin{document} |
| 47 |
\DocInput{texdate.dtx} |
| 48 |
\end{document} |
| 49 |
%</driver> \fi |
| 50 |
% |
| 51 |
% \title{The |texdate| Package, v2.0} |
| 52 |
% \author{Donald P.\ Goodman III} |
| 53 |
% \date{\today} |
| 54 |
% |
| 55 |
% \maketitle |
| 56 |
% |
| 57 |
% \begin{abstract} |
| 58 |
% \noindent |
| 59 |
% \TeX\ and \LaTeX\ provide few facilities for dates by |
| 60 |
% default, though many packages have filled this gap. |
| 61 |
% |texdate| fills it, as well, with a pure \TeX-primitive |
| 62 |
% implementation. It can print dates, advance them by |
| 63 |
% numbers of days, weeks, or months, determine the weekday |
| 64 |
% automatically, and print them in (mostly) arbitrary |
| 65 |
% format. It can also print calendars (monthly and yearly) |
| 66 |
% automatically, and can be easily localized for non-English |
| 67 |
% languages. |
| 68 |
% \end{abstract} |
| 69 |
% |
| 70 |
% \tableofcontents |
| 71 |
% |
| 72 |
% \section{Introduction: The State of the \TeX} |
| 73 |
% \label{sect:intro} |
| 74 |
% |
| 75 |
% \TeX\ by default contains very little facilities for |
| 76 |
% dealing with dates, and \LaTeX\ follows suit. As far as |
| 77 |
% primitives go, \TeX\ just offers the counters |\day|, |
| 78 |
% |\month|, and |\year|, which give the current values of |
| 79 |
% those units of time; e.g., |\the\year-\the\month-\the\day| |
| 80 |
% will yield ``\the\year-\the\month-\the\day'' (which is the |
| 81 |
% date on which this document was compiled). \LaTeX\ also |
| 82 |
% has |\today|, which will produce the current date in the |
| 83 |
% default American style: ``\today''. But that's |
| 84 |
% really about all there is. |
| 85 |
% |
| 86 |
% Many packages have attempted to fill up this gap, some |
| 87 |
% with excellent success; |datetime2| certain deserves |
| 88 |
% special mention here, particularly as it goes beyond what |
| 89 |
% |texdate| offers, given that |texdate| contains no |
| 90 |
% facilities for \emph{times} at all. |texdate| tries to fill the gap, |
| 91 |
% as well; but it does it using only \TeX-primitives, in the |
| 92 |
% hope that the solution will be (a) pretty fast, (b) |
| 93 |
% pretty portable, and (c) not requiring the loading of |
| 94 |
% massive packages, only a fraction of the capabilities of |
| 95 |
% which will actually be used. |
| 96 |
% |
| 97 |
% For comparison, |datetime2| uses |pgfcalendar|, which of |
| 98 |
% course requires |pgf|, which is a huge package. Our |
| 99 |
% modern computers make loading such packages often a |
| 100 |
% negligible overhead; but with large and complex documents, |
| 101 |
% it's not always trivial. Also, it's an enjoyable |
| 102 |
% challenge to write a usable package in \TeX\ for something |
| 103 |
% for which \TeX\ was not designed; and some of us enjoy |
| 104 |
% \emph{just knowing} that we're using a lean package, even |
| 105 |
% it makes little practical difference. |
| 106 |
% |
| 107 |
% This document is numbered in \emph{dozenal}, or base |
| 108 |
% twelve; numbering proceeds 1, 2, 3, 4, 5, 6, 7, 8, 9, \x, |
| 109 |
% \e, 10, 11, 12\xelip It uses the |dozenal| \LaTeX\ |
| 110 |
% package to do this. For more information, see |
| 111 |
% \url{http://www.dozenal.org}. |
| 112 |
% |
| 113 |
% \section{Dependencies} |
| 114 |
% \label{sect:deps} |
| 115 |
% |
| 116 |
% |texdate| requires the |padcount|, |modulus|, and |iflang| |
| 117 |
% packages internally, so be sure that they are installed. |
| 118 |
% They are all available on CTAN and in the \TeX{}Live |
| 119 |
% distribution. |
| 120 |
% |
| 121 |
% \section{Printing and Setting the Date} |
| 122 |
% \label{sect:basic} |
| 123 |
% |
| 124 |
% |texdate| works with an \emph{internal date}, which is the |
| 125 |
% current setting of all the date variables. When |
| 126 |
% initiated, the internal date is 1 January of the current |
| 127 |
% year. We can print that date with |
| 128 |
% \DescribeMacro{\printdate}|\printdate|: |
| 129 |
% |
| 130 |
% \bigskip |
| 131 |
% \hrule |
| 132 |
% \begin{Example} |
| 133 |
% \printdate |
| 134 |
% \end{Example} |
| 135 |
% \hrule |
| 136 |
% \bigskip |
| 137 |
% |
| 138 |
% We can easily set the internal date to the current date by |
| 139 |
% running the macro \DescribeMacro{\initcurrdate}|\initcurrdate|: |
| 140 |
% |
| 141 |
% \bigskip |
| 142 |
% \hrule |
| 143 |
% \begin{Example} |
| 144 |
% \initcurrdate |
| 145 |
% \printdate |
| 146 |
% \end{Example} |
| 147 |
% \hrule |
| 148 |
% \bigskip |
| 149 |
% |
| 150 |
% (This is the current date at the time this document was |
| 151 |
% compiled.) |
| 152 |
% |
| 153 |
% You can also easily \emph{set} the internal date, by |
| 154 |
% running the \DescribeMacro{\initdate}|\initdate| macro: |
| 155 |
% |
| 156 |
% \begin{quote} |
| 157 |
% \cmd{\initdate} \marg{year} \marg{month} \marg{day-of-month} |
| 158 |
% \end{quote} |
| 159 |
% |
| 160 |
% The elements of the date must be supplied to |\initdate| |
| 161 |
% in that order, or |texdate| will become confused. It's |
| 162 |
% obvious why; what should |texdate| do if the month is |
| 163 |
% entered as |2019|? |
| 164 |
% |
| 165 |
% \bigskip |
| 166 |
% \hrule |
| 167 |
% \begin{Example} |
| 168 |
% \initdate{2019}{6}{24} |
| 169 |
% \printdate |
| 170 |
% \end{Example} |
| 171 |
% \hrule |
| 172 |
% \bigskip |
| 173 |
% |
| 174 |
% While internally dates are kept as zero-indexed, these |
| 175 |
% dates are received by |\initdate| as one-indexed; that is, |
| 176 |
% |24| will mean the twenty-fourth, not the twenty-fifth, |
| 177 |
% because we count starting at 1 rather than 0. |
| 178 |
% |
| 179 |
% |
| 180 |
% \section{Date Formats} |
| 181 |
% \label{sect:dateforms} |
| 182 |
% |
| 183 |
% The date format we've seen so far is the default, which is |
| 184 |
% designed primarily to demonstrate several of the possible |
| 185 |
% variables that can be in a date format. Naturally, you'll |
| 186 |
% want to change it; and it can be changed, almost |
| 187 |
% arbitrarily, simply by redefining a command, or by using |
| 188 |
% one of several presets. |
| 189 |
% |
| 190 |
% \subsection{Preset Formats} |
| 191 |
% \label{sub:presetforms} |
| 192 |
% |
| 193 |
% |texdate| provides a number of preset formats that can be |
| 194 |
% easily selected without having to design a format string |
| 195 |
% (for which see Section \ref{sub:customforms}, on page |
| 196 |
% \pageref{sub:customforms}). |
| 197 |
% |
| 198 |
% \DescribeMacro{\printfdate\{ISO\}}|\printfdate{ISO}| |
| 199 |
% will print the current date in the default |
| 200 |
% ISO 8601 format, which is \emph{|yyyymmdd|}. In |
| 201 |
% |texdate|'s formatting strings, this is |Ymd|; you'll |
| 202 |
% learn more about these in Section \ref{sub:customforms}. |
| 203 |
% There is also the ``ISO extended'' form, |Y-m-d|. |
| 204 |
% |
| 205 |
% \bigskip |
| 206 |
% \hrule |
| 207 |
% \begin{Example} |
| 208 |
% \initdate{2019}{6}{24} |
| 209 |
% \printfdate{ISO} |
| 210 |
% |
| 211 |
% \printfdate{ISOext} |
| 212 |
% \end{Example} |
| 213 |
% \medskip |
| 214 |
% \hrule |
| 215 |
% \bigskip |
| 216 |
% |
| 217 |
% For Americans fond of our curious customary format, you |
| 218 |
% can use |
| 219 |
% \DescribeMacro{\printfdate\{american\}}|\printfdate{american}|; |
| 220 |
% in |texdate| format strings, this is |B\ d, Y|. There is |
| 221 |
% also |
| 222 |
% \DescribeMacro{\printfdate\{shamerican\}}|\printfdate{shamerican}|, |
| 223 |
% which is the abbreviated form, using slashes rather than |
| 224 |
% hyphens. |
| 225 |
% |
| 226 |
% \bigskip |
| 227 |
% \hrule |
| 228 |
% \begin{Example} |
| 229 |
% \initdate{2019}{6}{24} |
| 230 |
% \printfdate{american} |
| 231 |
% |
| 232 |
% \printfdate{shamerican} |
| 233 |
% \end{Example} |
| 234 |
% \medskip |
| 235 |
% \hrule |
| 236 |
% \bigskip |
| 237 |
% |
| 238 |
% The British also have their own ways of writing dates, |
| 239 |
% which correspond largely to the way the American military |
| 240 |
% writes them (which are consequently sometimes called |
| 241 |
% ``military dates,'' in the same way that twenty-four-hour |
| 242 |
% time readings are sometimes called ``military time''). |
| 243 |
% These are |
| 244 |
% \DescribeMacro{\printfdate\{british\}}|\printfdate{british}| |
| 245 |
% and |
| 246 |
% \DescribeMacro{\printfdate\{shbritish\}}|\printfdate{shbritish}|, |
| 247 |
% along with alternate form |
| 248 |
% \DescribeMacro{\printfdate\{shbritishdots\}}|\printfdate{shbritishdots}|, |
| 249 |
% |
| 250 |
% \bigskip |
| 251 |
% \hrule |
| 252 |
% \begin{Example} |
| 253 |
% \initdate{2019}{6}{24} |
| 254 |
% \printfdate{british} |
| 255 |
% |
| 256 |
% \printfdate{shbritish} |
| 257 |
% |
| 258 |
% \printfdate{shbritishdots} |
| 259 |
% \end{Example} |
| 260 |
% \medskip |
| 261 |
% \hrule |
| 262 |
% \bigskip |
| 263 |
% |
| 264 |
% This is enough to cover the standards of most places in |
| 265 |
% the world. However, if you want something different, you |
| 266 |
% can easily create it with format strings. |
| 267 |
% |
| 268 |
% \subsection{Custom Date Formats} |
| 269 |
% \label{sub:customforms} |
| 270 |
% |
| 271 |
% All the custom formats described in Section |
| 272 |
% \ref{sub:presetforms} and printed with |\printfdate| are |
| 273 |
% created using the same general mechanism described in this |
| 274 |
% section. We will begin by discussing a way to generically |
| 275 |
% change the presentation of all dates called with the basic |
| 276 |
% |\printdate|, then move on to creating custom date formats |
| 277 |
% that can be printed by name with |\printfdate|. |
| 278 |
% |
| 279 |
% The macro \DescribeMacro{\setdateformat}|\setdateformat| |
| 280 |
% holds the formatting string for the date. It's not |
| 281 |
% \emph{completely} arbitrary, because none of the |
| 282 |
% characters used to produce specific parts of the date can |
| 283 |
% be used in the string itself; however, it's pretty |
| 284 |
% flexible despite that limitation. |
| 285 |
% |
| 286 |
% The default date format string, quite unsuitable for real |
| 287 |
% work, includes most of the possible control characters, |
| 288 |
% and is |A{ }(a),\ B\ (b){ }d,\ Y|. Note that spaces |
| 289 |
% have to be preserved by either \emph{bracing} them or |
| 290 |
% \emph{escaping} them; that is, to put a space in your |
| 291 |
% format string, use either ``|\ |'' or ``|{ }|''. |
| 292 |
% |
| 293 |
% Table \ref{tab:lets} on page \pageref{tab:lets} shows |
| 294 |
% the control characters, an |
| 295 |
% explanation of their meaning, and an example of each. |
| 296 |
% They assume the date 4 June 2019, selected by |
| 297 |
% |\initdate{2019}{6}{4}|. |
| 298 |
% \initdate{2019}{6}{4} |
| 299 |
% |
| 300 |
% \begin{table}[htp] |
| 301 |
% \centering |
| 302 |
% \begin{tabular}{lp{3in}l} |
| 303 |
% \toprule |
| 304 |
% \itshape Let. & \itshape Result & \itshape Ex. \\ |
| 305 |
% \midrule |
| 306 |
% d & Numeric day of the month; 0-padded to two digits if |
| 307 |
% necessary & \printfdate{d} \\ |
| 308 |
% e & Numeric day of the month; space-padded to two spaces |
| 309 |
% if necessary & \printfdate{e} \\ |
| 310 |
% B & Full name of the month & \printfdate{B} \\ |
| 311 |
% b & Abbreviated name of the month & \printfdate{b} \\ |
| 312 |
% h & Abbreviated name of the month; same as |b| & \printfdate{h} \\ |
| 313 |
% m & Number of month, with January as 1; 0-padded to two |
| 314 |
% digits if necessary & \printfdate{m} \\ |
| 315 |
% A & Full name of the weekday & \printfdate{A} \\ |
| 316 |
% a & Abbreviated name of the weekday & \printfdate{a} \\ |
| 317 |
% w & Numeric value of weekday, with Sunday as 0 & \printfdate{w} \\ |
| 318 |
% u & ISO numeric value of weekday, with Monday as 1 and |
| 319 |
% Sunday as 7 & \printfdate{u} \\ |
| 320 |
% Y & Number of the current year & \printfdate{Y} \\ |
| 321 |
% j & Numeric day of the year, starting on a constant count |
| 322 |
% from 1 Jan; 0-padded to three digits if necessary & \printfdate{j} \\ |
| 323 |
% C & Century; essentially, the first two digits of the year & |
| 324 |
% \printfdate{C} \\ |
| 325 |
% y & The year, in only two digits & \printfdate{y} \\ |
| 326 |
% U & Week number of the year, starting at 0, with the week |
| 327 |
% starting on Sunday; 0-padded to two digits if |
| 328 |
% necessary & \printfdate{U} \\ |
| 329 |
% V & ISO week number of the year, starting at 1, with the week |
| 330 |
% starting on Monday; 0-padded to two digits if |
| 331 |
% necessary & \printfdate{V} \\ |
| 332 |
% W & Week number of the year, starting at 0, with the week |
| 333 |
% starting on Monday; 0-padded to two digits if necesary & |
| 334 |
% \printfdate{W} \\ |
| 335 |
% \bottomrule |
| 336 |
% \end{tabular} |
| 337 |
% \caption{Control codes for date formats} |
| 338 |
% \label{tab:lets} |
| 339 |
% \end{table} |
| 340 |
% |
| 341 |
% For folks not familiar with the \emph{control characters} |
| 342 |
% concept, the essential idea is that you format some |
| 343 |
% information with a certain ``string,'' called the ``format |
| 344 |
% string.'' The format string contains some characters |
| 345 |
% which are meaningless as far as formatting goes, and are |
| 346 |
% passed through unchanged; and some characters which will |
| 347 |
% be replaced with certain information. In other words, |
| 348 |
% assume that we have a format string consisting of the |
| 349 |
% following characters: |a b c d e|. |c| is a control |
| 350 |
% character, and represents the information ``zzz''; the other |
| 351 |
% characters are not control characters. |
| 352 |
% |
| 353 |
% \begin{quote} |
| 354 |
% |a b c d e| $\rightarrow$ a b zzz d e |
| 355 |
% \end{quote} |
| 356 |
% |
| 357 |
% Anyone who has used GNU |
| 358 |
% |date| or BSD |date| will recognize these control |
| 359 |
% characters, though of course in those programs a |%| |
| 360 |
% character would be necessary, as well. |texdate| |
| 361 |
% duplicates the behavior of these programs as closely as |
| 362 |
% my \TeX-pertise allows. |
| 363 |
% |
| 364 |
% \bigskip |
| 365 |
% \hrule |
| 366 |
% \begin{Example} |
| 367 |
% \initcurrdate |
| 368 |
% \advancebyweeks{6} |
| 369 |
% \def\setdateformat{d\ B\ Y} |
| 370 |
% |d\ B\ Y|: \printdate\par |
| 371 |
% \def\setdateformat{Y-m-d} |
| 372 |
% |Y-m-d|: \printdate\par |
| 373 |
% \def\setdateformat{a,\ d\ b\ Y} |
| 374 |
% |a,\ d\ b\ Y|: \printdate\par |
| 375 |
% \end{Example} |
| 376 |
% \medskip |
| 377 |
% \hrule |
| 378 |
% \bigskip |
| 379 |
% |
| 380 |
% We can meddle with this however we like, except that these |
| 381 |
% control characters (the ones that turn into elements of |
| 382 |
% the date) cannot be included literally. |
| 383 |
% |
| 384 |
% You can also define \emph{named date formats}: |
| 385 |
% \DescribeMacro{\nameddateformat} |
| 386 |
% |
| 387 |
% \begin{quote} |
| 388 |
% \cmd{\nameddateformat} \marg{name} \marg{format-string} |
| 389 |
% \end{quote} |
| 390 |
% |
| 391 |
% Perhaps I want a peculiar date format, with the month, |
| 392 |
% followed by the year, followed by the day of the month, |
| 393 |
% followed by the day of the year in parentheses. My format |
| 394 |
% string should be |m-Y-d\ (j)|. I'll then want to use the |
| 395 |
% \DescribeMacro{\printfdate}|\printfdate| command with its single |
| 396 |
% argument, which is the name of the date format I want to |
| 397 |
% use. |
| 398 |
% |
| 399 |
% \bigskip |
| 400 |
% \hrule |
| 401 |
% \begin{Example} |
| 402 |
% \initcurrdate |
| 403 |
% \nameddateformat{weird}{m-Y-d\ (j)} |
| 404 |
% \printfdate{weird}\par |
| 405 |
% \printdate |
| 406 |
% \end{Example} |
| 407 |
% \medskip |
| 408 |
% \hrule |
| 409 |
% \bigskip |
| 410 |
% |
| 411 |
% It's worth nothing that all of the control characters also |
| 412 |
% have a formatted print string that can be called by name. |
| 413 |
% So one could duplicate the above |weird| date format the |
| 414 |
% hard way, by using these each individually: |
| 415 |
% |
| 416 |
% \bigskip |
| 417 |
% \hrule |
| 418 |
% \begin{Example} |
| 419 |
% \initcurrdate |
| 420 |
% \printfdate{m}-\printfdate{Y}-\printfdate{d} (\printfdate{j}) |
| 421 |
% \end{Example} |
| 422 |
% \medskip |
| 423 |
% \hrule |
| 424 |
% \bigskip |
| 425 |
% |
| 426 |
% These seems a bit convoluted, but perhaps you want to wrap |
| 427 |
% it in a macro? |
| 428 |
% |
| 429 |
% \subsection{Number Format} |
| 430 |
% \label{sub:numforms} |
| 431 |
% |
| 432 |
% Any command which will work on a \TeX\ count register can |
| 433 |
% be inserted into the |
| 434 |
% \DescribeMacro{\texdatenumformat}|\texdatenumformat| |
| 435 |
% command, which will be applied to all the numbers which |
| 436 |
% |texdate| outputs. For example, if you are using the |
| 437 |
% |dozenal| package: |
| 438 |
% |
| 439 |
% \bigskip |
| 440 |
% \hrule |
| 441 |
% \begin{Example} |
| 442 |
% \def\texdatenumformat#1{\dozens{#1}} |
| 443 |
% \initdate{2018}{12}{25} |
| 444 |
% \printfdate{ISOext} |
| 445 |
% \end{Example} |
| 446 |
% \medskip |
| 447 |
% \hrule |
| 448 |
% \bigskip |
| 449 |
% |
| 450 |
% |
| 451 |
% \section{Manipulating Dates} |
| 452 |
% \label{sect:manipdate} |
| 453 |
% |
| 454 |
% |texdate| goes well beyond merely printing and setting |
| 455 |
% dates; you can manipulate them in many ways. The original |
| 456 |
% purpose of the package was to allow \LaTeX\ to print |
| 457 |
% calendar sheets and things of that nature without |
| 458 |
% resorting to an external program, or loading some enormous |
| 459 |
% package, so it needed the ability to move forward and |
| 460 |
% backward by given increments. So we have that. |
| 461 |
% |
| 462 |
% \subsection{Moving Dates Forward and Backward} |
| 463 |
% \label{sub:movedate} |
| 464 |
% |
| 465 |
% You can advance the date by a certain number of days, |
| 466 |
% weeks, or months. The macros are named, unsurprisingly, |
| 467 |
% \DescribeMacro{\advancebydays}|\advancebydays|, |
| 468 |
% \DescribeMacro{\advancebyweeks}|\advancebyweeks|, and |
| 469 |
% \DescribeMacro{\advancebymonths}|\advancebymonths|, each |
| 470 |
% of which takes one argument, which is the number of that |
| 471 |
% unit you wish to advance the date by. The corresponding |
| 472 |
% commands \DescribeMacro{\regressbydays}|\regressbydays|, |
| 473 |
% \DescribeMacro{\regressbyweeks}|\regressbyweeks|, and |
| 474 |
% \DescribeMacro{\regressbymonths}|\regressbymonths| also |
| 475 |
% exist. |
| 476 |
% |
| 477 |
% \bigskip |
| 478 |
% \hrule |
| 479 |
% \begin{Example} |
| 480 |
% \initcurrdate |
| 481 |
% Current date: \printdate\par |
| 482 |
% \advancebydays{8} |
| 483 |
% 8 days later: \printdate\par |
| 484 |
% \advancebyweeks{4} |
| 485 |
% 4 weeks later: \printdate\par |
| 486 |
% \advancebymonths{4} |
| 487 |
% 4 months later: \printdate\par |
| 488 |
% \regressbydays{14} |
| 489 |
% 14 days earlier: \printdate\par |
| 490 |
% \regressbyweeks{8} |
| 491 |
% 8 weeks earlier: \printdate\par |
| 492 |
% \regressbymonths{2} |
| 493 |
% 2 months earlier: \printdate\par |
| 494 |
% \end{Example} |
| 495 |
% \nobreak\medskip\nobreak |
| 496 |
% \hrule |
| 497 |
% \bigskip |
| 498 |
% |
| 499 |
% Note that |\advancebymonths| does not validate the date, |
| 500 |
% so it's possible that you'll end up with something |
| 501 |
% impossible, such as 31 September. It's best to watch the |
| 502 |
% results of this one carefully. |
| 503 |
% |
| 504 |
% Both the |\advanceby|s and the |\regressby|s should be |
| 505 |
% given positive numbers; negative numbers will just confuse |
| 506 |
% them. |
| 507 |
% |
| 508 |
% \subsection{Saving and Restoring Dates} |
| 509 |
% \label{sub:savedate} |
| 510 |
% |
| 511 |
% Sometimes you may wish to save a date, change the internal |
| 512 |
% date, use that internal date for a while, then restore the |
| 513 |
% old date. |texdate| makes it possible to save and use as |
| 514 |
% many dates as you want (or, at any rate, as many as \TeX\ |
| 515 |
% will tolerate). |
| 516 |
% |
| 517 |
% \DescribeMacro{\savedate}|\savedate| takes a single |
| 518 |
% argument, the \emph{name} you'd like to give your saved |
| 519 |
% date. This can be anything that \TeX\ allows in a control |
| 520 |
% sequence; best to stick with normal, seven-bit ASCII |
| 521 |
% letters. You then access the saved date with |
| 522 |
% \DescribeMacro{\restoredate}|\restoredate|, which takes |
| 523 |
% that same name as its argument. |
| 524 |
% |
| 525 |
% \bigskip |
| 526 |
% \hrule |
| 527 |
% \begin{Example} |
| 528 |
% \initcurrdate |
| 529 |
% \printdate\par |
| 530 |
% \savedate{current} |
| 531 |
% \advancebyweeks{12} |
| 532 |
% \printdate\par |
| 533 |
% \savedate{advanced} |
| 534 |
% \restoredate{current} |
| 535 |
% \printdate\par |
| 536 |
% \advancebydays{3} |
| 537 |
% \printdate\par |
| 538 |
% \restoredate{advanced} |
| 539 |
% \printdate\par |
| 540 |
% \restoredate{current} |
| 541 |
% \printdate\par |
| 542 |
% \end{Example} |
| 543 |
% \medskip |
| 544 |
% \hrule |
| 545 |
% \bigskip |
| 546 |
% |
| 547 |
% You can also retrieve your saved date directly; rather |
| 548 |
% than calling |\restoredate|, you can call |
| 549 |
% |\savedate<name>|, without the angle brackets. That's the |
| 550 |
% name that |texdate| uses internally, and calls with |
| 551 |
% |\restoredate| to get your information back. |
| 552 |
% |
| 553 |
% |
| 554 |
% \section{Convenience Macros} |
| 555 |
% \label{sect:convmacs} |
| 556 |
% |
| 557 |
% |texdate| offers a few macros for tasks which its author |
| 558 |
% anticipates will likely be common. For example, to |
| 559 |
% produce a small monthly calendar, consider using the |
| 560 |
% |\texdcal| macro, which takes two arguments: the year and |
| 561 |
% the month of the calendar you're seeking to create: |
| 562 |
% |
| 563 |
% \bigskip |
| 564 |
% \hrule |
| 565 |
% \begin{Example} |
| 566 |
% \begin{center} |
| 567 |
% \begin{tabular}{cc} |
| 568 |
% \texdcal{2018}{5} & |
| 569 |
% \texdcal{2018}{6} \\ |
| 570 |
% \texdcal{2018}{8} & |
| 571 |
% \texdcal{2018}{9} \\ |
| 572 |
% \end{tabular} |
| 573 |
% \end{center} |
| 574 |
% \end{Example} |
| 575 |
% \medskip |
| 576 |
% \hrule |
| 577 |
% \bigskip |
| 578 |
% |
| 579 |
% Notice that |\texdcal| does the right thing when there a |
| 580 |
% month goes into an extra week: it simply prints another |
| 581 |
% week. It also correctly refuses to print the days of a |
| 582 |
% week which do not belong to the requested month. |
| 583 |
% |
| 584 |
% \DescribeMacro{\texdcalyear}|\texdcalyear| will produce |
| 585 |
% one of these calendars for an entire year, in three |
| 586 |
% columns; the year chosen is the argument given to the |
| 587 |
% macro. Because the margins of the \LaTeX\ standard |
| 588 |
% classes are much too large (or rather, the paper sizes are |
| 589 |
% much too large; the text blocks are rather nicely |
| 590 |
% proportioned), |\texdcalyear| prints this calendar in a |
| 591 |
% small size, with very small space between columns. |
| 592 |
% |
| 593 |
% \bigskip |
| 594 |
% \hrule |
| 595 |
% \begin{Example} |
| 596 |
% \footnotesize% |
| 597 |
% \begin{center} |
| 598 |
% \texdcalyear{2018} |
| 599 |
% \end{center} |
| 600 |
% \end{Example} |
| 601 |
% \medskip |
| 602 |
% \hrule |
| 603 |
% \bigskip |
| 604 |
% |
| 605 |
% Obviously, it uses |\texdcal| internally to do this, so |
| 606 |
% the definition of |\texdcalyear| is much simpler than that |
| 607 |
% of |\texdcal|. |
| 608 |
% |
| 609 |
% Just as obviously, these yearly calendars |
| 610 |
% could easily be formatted in many different ways; so many, |
| 611 |
% in fact, that attempting to make the macros flexible |
| 612 |
% enough for meaningful customization would be prohibitively |
| 613 |
% difficult. More fruitful results can be obtained by |
| 614 |
% reading the macros themselves (they are truly not very |
| 615 |
% difficult) and customizing them oneself. |
| 616 |
% |
| 617 |
% \section{Language Specification} |
| 618 |
% \label{sect:lang} |
| 619 |
% |
| 620 |
% |texdate| does understand \LaTeX\ language specifications, |
| 621 |
% using Heiko Oberdiek's |iflang| package, which should work |
| 622 |
% for both |babel| and |polyglossia|. Built-in are |
| 623 |
% only English (the default), Spanish, French, and German. |
| 624 |
% However, it's pretty simple to customize the |
| 625 |
% month name and weekday name strings by defining a few |
| 626 |
% commands, so if you need a different language, you just |
| 627 |
% need to redefine a few strings. |
| 628 |
% |
| 629 |
% Each string begins with the prefix |\texd@|, then the |
| 630 |
% English ordinal string for the order in which it comes, |
| 631 |
% with January being the first month and Sunday being the |
| 632 |
% first weekday; e.g., |\texd@first|. Then comes |sh| if |
| 633 |
% it's an abbreviation; e.g., |\texd@firstsh|. Finally |
| 634 |
% comes the string |mon| if it's a month, or |name| if |
| 635 |
% it's a weekday name. Below is the complete list, for |
| 636 |
% German. |
| 637 |
% |
| 638 |
% \begin{quote} |
| 639 |
% |\makeatletter|\\ |
| 640 |
% |\def\texd@firstmon{Januar}|\\ |
| 641 |
% |\def\texd@firstshmon{Jan}|\\ |
| 642 |
% |\def\texd@secondmon{Februar}|\\ |
| 643 |
% |\def\texd@secondshmon{Feb}|\\ |
| 644 |
% |\def\texd@thirdmon{März}|\\ |
| 645 |
% |\def\texd@thirdshmon{März}|\\ |
| 646 |
% |\def\texd@fourthmon{April}|\\ |
| 647 |
% |\def\texd@fourthshmon{Apr}|\\ |
| 648 |
% |\def\texd@fifthmon{Mai}|\\ |
| 649 |
% |\def\texd@fifthshmon{Mai}|\\ |
| 650 |
% |\def\texd@sixthmon{Juni}|\\ |
| 651 |
% |\def\texd@sixthshmon{Juni}|\\ |
| 652 |
% |\def\texd@seventhmon{Juli}|\\ |
| 653 |
% |\def\texd@seventhshmon{Juli}|\\ |
| 654 |
% |\def\texd@eighthmon{August}|\\ |
| 655 |
% |\def\texd@eighthshmon{Aug}|\\ |
| 656 |
% |\def\texd@ninthmon{September}|\\ |
| 657 |
% |\def\texd@ninthshmon{Sept}|\\ |
| 658 |
% |\def\texd@tenthmon{Oktober}|\\ |
| 659 |
% |\def\texd@tenthshmon{Okt}|\\ |
| 660 |
% |\def\texd@eleventhmon{November}|\\ |
| 661 |
% |\def\texd@eleventhshmon{Nov}|\\ |
| 662 |
% |\def\texd@twelfthmon{Dezember}|\\ |
| 663 |
% |\def\texd@twelfthshmon{Dez}|\\ |
| 664 |
% |\def\texd@firstdayname{Sonntag}|\\ |
| 665 |
% |\def\texd@firstdayshname{So}|\\ |
| 666 |
% |\def\texd@seconddayname{Montag}|\\ |
| 667 |
% |\def\texd@seconddayshname{Mo}|\\ |
| 668 |
% |\def\texd@thirddayname{Dienstag}|\\ |
| 669 |
% |\def\texd@thirddayshname{Di}|\\ |
| 670 |
% |\def\texd@fourthdayname{Mittwoch}|\\ |
| 671 |
% |\def\texd@fourthdayshname{Mi}|\\ |
| 672 |
% |\def\texd@fifthdayname{Donnerstag}|\\ |
| 673 |
% |\def\texd@fifthdayshname{Do}|\\ |
| 674 |
% |\def\texd@sixthdayname{Freitag}|\\ |
| 675 |
% |\def\texd@sixthdayshname{Fr}|\\ |
| 676 |
% |\def\texd@seventhdayname{Samstag}|\\ |
| 677 |
% |\def\texd@seventhdayshname{Sa}|\\ |
| 678 |
% |\makeatother| |
| 679 |
% \end{quote} |
| 680 |
% |
| 681 |
% Doing something like this for your desired language, |
| 682 |
% \emph{after} you've loaded |texdate|, will localize all |
| 683 |
% the strings involved. |
| 684 |
% |
| 685 |
% \section{Plain \TeX\ Usage} |
| 686 |
% |
| 687 |
% I was asked recently, quite unexpectedly, whether |
| 688 |
% |texdate| could be used with plain \TeX. My initial |
| 689 |
% thought was an obvious ``yes,'' since it's implemented |
| 690 |
% entirely with \TeX\ primitives; however, the matter wasn't |
| 691 |
% quite that simple. The package file does use some |
| 692 |
% \LaTeX-specific macros, all related to the packaging |
| 693 |
% itself; and it uses a |padcount| macro which doesn't work |
| 694 |
% with plain \TeX. Also, according to \LaTeX\ convention, |
| 695 |
% it uses |@| as a letter in control sequences willy-nilly, |
| 696 |
% and \TeX\ balks at such craziness. Finally, a small |
| 697 |
% change in the code (due to deep \TeX\ magic involving |
| 698 |
% |\outer| that is best left unspoken) needed to be made. |
| 699 |
% This done, however, the package \emph{can} (mostly) be |
| 700 |
% used in plain \TeX. Here's how. |
| 701 |
% |
| 702 |
% The following must be included in your document in order |
| 703 |
% to prevent \TeX\ from choking on our \LaTeX\ packaging |
| 704 |
% macros: |
| 705 |
% |
| 706 |
% \begin{quote} |
| 707 |
% |\def\NeedsTeXFormat#1[#2]{}|\\ |
| 708 |
% |\def\ProvidesPackage#1[#2]{}|\\ |
| 709 |
% |\def\RequirePackage#1{}|\\ |
| 710 |
% |\def\AtBeginDocument#1{}|\\ |
| 711 |
% \end{quote} |
| 712 |
% |
| 713 |
% This simply defines these macros to do nothing, which is |
| 714 |
% how \TeX\ prefers packaging macros to work. Then, you |
| 715 |
% need to tell \TeX\ that |@| can, in fact, be part of the |
| 716 |
% name of a control sequence: |
| 717 |
% |
| 718 |
% \begin{quote} |
| 719 |
% |\catcode`@=11| |
| 720 |
% \end{quote} |
| 721 |
% |
| 722 |
% This, again, is some deep \TeX\ magic best left |
| 723 |
% undiscussed for the benefit of those not interested. |
| 724 |
% There's plenty of information around if you really want |
| 725 |
% it. Finally, we need to input the packages that |texdate| |
| 726 |
% needs, and tell \TeX\ not to use the |
| 727 |
% |padcount| macro that it doesn't like, by redefining it to |
| 728 |
% simply spit out its own parameter: |
| 729 |
% |
| 730 |
% \begin{quote} |
| 731 |
% |\input modulus.sty|\\ |
| 732 |
% |\input padcount.sty|\\ |
| 733 |
% |\input texdate.sty|\\ |
| 734 |
% |\def\padnum#1{#1}|\\ |
| 735 |
% \end{quote} |
| 736 |
% |
| 737 |
% These things done, |texdate| will work almost entirely |
| 738 |
% with plain \TeX, except that (obviously) the padding |
| 739 |
% options won't have any effect. So, if plain \TeX\ is your |
| 740 |
% preference, go for it. |
| 741 |
% |
| 742 |
% |
| 743 |
% \section{Implementation} |
| 744 |
% |
| 745 |
% \begin{macrocode} |
| 746 |
\RequirePackage{modulus}% |
| 747 |
\RequirePackage{padcount}% |
| 748 |
\RequirePackage{iflang}% |
| 749 |
\newcount\texd@loopi\texd@loopi=0% |
| 750 |
\newcount\texd@mon\texd@mon=0% |
| 751 |
\newcount\texd@dow\texd@dow=0% |
| 752 |
\newcount\texd@dom\texd@dom=0% |
| 753 |
\newcount\texd@yr\texd@yr=\year% |
| 754 |
\newcount\texd@rdom\texd@rdom=\texd@dom\advance\texd@rdom by1% |
| 755 |
\newcount\texd@rmon% |
| 756 |
%% taken from dayofweek.tex, by Martin Minow of DEC; |
| 757 |
%% included in TeXLive |
| 758 |
\newcount\texd@dow% Gets day of the week |
| 759 |
\newcount\texd@leap% Leap year fingaler |
| 760 |
\newcount\texd@x% Temp register |
| 761 |
\newcount\texd@y% Another temp register |
| 762 |
\def\texd@nextdow#1#2#3{% |
| 763 |
\global\texd@leap=#2% |
| 764 |
\global\advance\texd@leap by-14% |
| 765 |
\global\divide\texd@leap by12% |
| 766 |
\global\advance\texd@leap by#3% |
| 767 |
\global\texd@dow=#2% |
| 768 |
\global\advance\texd@dow by10% |
| 769 |
\global\texd@y=\texd@dow% |
| 770 |
\global\divide\texd@y by13% |
| 771 |
\global\multiply\texd@y by12% |
| 772 |
\global\advance\texd@dow by-\texd@y% |
| 773 |
\global\multiply\texd@dow by13% |
| 774 |
\global\advance\texd@dow by-1% |
| 775 |
\global\divide\texd@dow by5% |
| 776 |
\global\advance\texd@dow by#1% |
| 777 |
\global\advance\texd@dow by77% |
| 778 |
\global\texd@x=\texd@leap% |
| 779 |
\global\texd@y=\texd@x% |
| 780 |
\global\divide\texd@y by100% |
| 781 |
\global\multiply\texd@y by100% |
| 782 |
\global\advance\texd@x by-\texd@y% |
| 783 |
\global\multiply\texd@x by5% |
| 784 |
\global\divide\texd@x by4% |
| 785 |
\global\advance\texd@dow by\texd@x% |
| 786 |
\global\texd@x=\texd@leap% |
| 787 |
\global\divide\texd@x by400% |
| 788 |
\global\advance\texd@dow by\texd@x% |
| 789 |
\global\texd@x=\texd@leap% |
| 790 |
\global\divide\texd@x by100% |
| 791 |
\global\multiply\texd@x by2% |
| 792 |
\global\advance\texd@dow by-\texd@x% |
| 793 |
\global\texd@x=\texd@dow% |
| 794 |
\global\divide\texd@x by7% |
| 795 |
\global\multiply\texd@x by7% |
| 796 |
\global\advance\texd@dow by-\texd@x% |
| 797 |
} |
| 798 |
%% end taken from dayofweek.tex, by Martin Minow of DEC; |
| 799 |
%% included in TeXLive |
| 800 |
\def\texd@leapyear{% |
| 801 |
}% |
| 802 |
\def\texd@downame{% |
| 803 |
\ifcase\texd@dow |
| 804 |
\texd@firstdayname% |
| 805 |
\or% |
| 806 |
\texd@seconddayname% |
| 807 |
\or% |
| 808 |
\texd@thirddayname% |
| 809 |
\or% |
| 810 |
\texd@fourthdayname% |
| 811 |
\or% |
| 812 |
\texd@fifthdayname% |
| 813 |
\or% |
| 814 |
\texd@sixthdayname% |
| 815 |
\or% |
| 816 |
\texd@seventhdayname% |
| 817 |
\fi% |
| 818 |
}% |
| 819 |
\def\texd@shdowname{% |
| 820 |
\ifcase\texd@dow |
| 821 |
\texd@firstdayshname% |
| 822 |
\or% |
| 823 |
\texd@seconddayshname% |
| 824 |
\or% |
| 825 |
\texd@thirddayshname% |
| 826 |
\or% |
| 827 |
\texd@fourthdayshname% |
| 828 |
\or% |
| 829 |
\texd@fifthdayshname% |
| 830 |
\or% |
| 831 |
\texd@sixthdayshname% |
| 832 |
\or% |
| 833 |
\texd@seventhdayshname% |
| 834 |
\fi% |
| 835 |
}% |
| 836 |
\def\texd@nextmonth{% |
| 837 |
\ifnum\texd@mon<11\global\advance\texd@mon by1\fi% |
| 838 |
\ifnum\texd@mon=11\global\texd@mon=0\fi% |
| 839 |
}% |
| 840 |
\def\texd@lastmonth{% |
| 841 |
\ifnum\texd@mon=0% |
| 842 |
\global\texd@mon=11% |
| 843 |
\global\advance\texd@yr by-1% |
| 844 |
\fi% |
| 845 |
\ifnum\texd@mon>0\global\advance\texd@mon by-1\fi% |
| 846 |
}% |
| 847 |
\def\texd@nextdate{% |
| 848 |
\ifnum\texd@mon=11% |
| 849 |
\ifnum\texd@dom=30% |
| 850 |
\global\advance\texd@yr by1% |
| 851 |
\global\texd@mon=0% |
| 852 |
\global\texd@dom=0% |
| 853 |
\fi% |
| 854 |
\ifnum\texd@dom<30% |
| 855 |
\global\advance\texd@dom by1% |
| 856 |
\fi% |
| 857 |
\else\ifnum\texd@mon=10% |
| 858 |
\ifnum\texd@dom=29% |
| 859 |
\global\advance\texd@mon by1%% |
| 860 |
\global\texd@dom=0% |
| 861 |
\fi% |
| 862 |
\ifnum\texd@dom<29% |
| 863 |
\global\advance\texd@dom by1% |
| 864 |
\fi% |
| 865 |
\else\ifnum\texd@mon=9% |
| 866 |
\ifnum\texd@dom=30% |
| 867 |
\global\advance\texd@mon by1%% |
| 868 |
\global\texd@dom=0% |
| 869 |
\fi% |
| 870 |
\ifnum\texd@dom<30% |
| 871 |
\global\advance\texd@dom by1% |
| 872 |
\fi% |
| 873 |
\else\ifnum\texd@mon=8% |
| 874 |
\ifnum\texd@dom=29% |
| 875 |
\global\advance\texd@mon by1%% |
| 876 |
\global\texd@dom=0% |
| 877 |
\fi% |
| 878 |
\ifnum\texd@dom<29% |
| 879 |
\global\advance\texd@dom by1% |
| 880 |
\fi% |
| 881 |
\else\ifnum\texd@mon=7% |
| 882 |
\ifnum\texd@dom=30% |
| 883 |
\global\advance\texd@mon by1%% |
| 884 |
\global\texd@dom=0% |
| 885 |
\fi% |
| 886 |
\ifnum\texd@dom<30% |
| 887 |
\global\advance\texd@dom by1% |
| 888 |
\fi% |
| 889 |
\else\ifnum\texd@mon=6% |
| 890 |
\ifnum\texd@dom=30% |
| 891 |
\global\advance\texd@mon by1%% |
| 892 |
\global\texd@dom=0% |
| 893 |
\fi% |
| 894 |
\ifnum\texd@dom<30% |
| 895 |
\global\advance\texd@dom by1% |
| 896 |
\fi% |
| 897 |
\else\ifnum\texd@mon=5% |
| 898 |
\ifnum\texd@dom=29% |
| 899 |
\global\advance\texd@mon by1%% |
| 900 |
\global\texd@dom=0% |
| 901 |
\fi% |
| 902 |
\ifnum\texd@dom<29% |
| 903 |
\global\advance\texd@dom by1% |
| 904 |
\fi% |
| 905 |
\else\ifnum\texd@mon=4% |
| 906 |
\ifnum\texd@dom=30% |
| 907 |
\global\advance\texd@mon by1%% |
| 908 |
\global\texd@dom=0% |
| 909 |
\fi% |
| 910 |
\ifnum\texd@dom<30% |
| 911 |
\global\advance\texd@dom by1% |
| 912 |
\fi% |
| 913 |
\else\ifnum\texd@mon=3% |
| 914 |
\ifnum\texd@dom=29% |
| 915 |
\global\advance\texd@mon by1%% |
| 916 |
\global\texd@dom=0% |
| 917 |
\fi% |
| 918 |
\ifnum\texd@dom<29% |
| 919 |
\global\advance\texd@dom by1% |
| 920 |
\fi% |
| 921 |
\else\ifnum\texd@mon=2% |
| 922 |
\ifnum\texd@dom=30% |
| 923 |
\global\advance\texd@mon by1%% |
| 924 |
\global\texd@dom=0% |
| 925 |
\fi |
| 926 |
\ifnum\texd@dom<30% |
| 927 |
\global\advance\texd@dom by1% |
| 928 |
\fi% |
| 929 |
\else\ifnum\texd@mon=1% |
| 930 |
\ifnum\texd@leapyear=0% |
| 931 |
\ifnum\texd@dom=27% |
| 932 |
\global\advance\texd@mon by1% |
| 933 |
\global\texd@dom=0% |
| 934 |
\fi |
| 935 |
\ifnum\texd@dom<27% |
| 936 |
\global\advance\texd@dom by1% |
| 937 |
\fi% |
| 938 |
\else\ifnum\texd@leapyear=1% |
| 939 |
\ifnum\texd@dom=28% |
| 940 |
\global\advance\texd@mon by1% |
| 941 |
\global\texd@dom=0% |
| 942 |
\fi% |
| 943 |
\ifnum\texd@dom<28% |
| 944 |
\global\advance\texd@dom by1% |
| 945 |
\fi% |
| 946 |
\fi\fi% |
| 947 |
\else\ifnum\texd@mon=0% |
| 948 |
\ifnum\texd@dom=30% |
| 949 |
\global\advance\texd@mon by1%% |
| 950 |
\global\texd@dom=0% |
| 951 |
\fi% |
| 952 |
\ifnum\texd@dom<30% |
| 953 |
\global\advance\texd@dom by1% |
| 954 |
\fi% |
| 955 |
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% |
| 956 |
\global\texd@rdom=\texd@dom\global\advance\texd@rdom by1% |
| 957 |
\global\texd@rmon=\texd@mon\global\advance\texd@rmon by1% |
| 958 |
\texd@setjnum% |
| 959 |
\texd@nextdow{\the\texd@rdom}{\the\texd@rmon}{\the\texd@yr}% |
| 960 |
}% |
| 961 |
\def\texd@lastdate{% |
| 962 |
\global\advance\texd@dom by-1% |
| 963 |
\ifnum\texd@dom=0% |
| 964 |
\global\advance\texd@mon by-1% |
| 965 |
\ifnum\texd@mon=11% |
| 966 |
\global\texd@dom=30% |
| 967 |
\fi% |
| 968 |
\ifnum\texd@mon=0% |
| 969 |
\global\texd@mon=11% |
| 970 |
\global\advance\texd@yr by-1% |
| 971 |
\global\texd@dom=30% |
| 972 |
\fi% |
| 973 |
\ifnum\texd@mon=10% |
| 974 |
\global\texd@dom=29% |
| 975 |
\fi% |
| 976 |
\ifnum\texd@mon=9% |
| 977 |
\global\texd@dom=30% |
| 978 |
\fi% |
| 979 |
\ifnum\texd@mon=8% |
| 980 |
\global\texd@dom=29% |
| 981 |
\fi% |
| 982 |
\ifnum\texd@mon=7% |
| 983 |
\global\texd@dom=30% |
| 984 |
\fi% |
| 985 |
\ifnum\texd@mon=6% |
| 986 |
\global\texd@dom=30% |
| 987 |
\fi% |
| 988 |
\ifnum\texd@mon=5% |
| 989 |
\global\texd@dom=29% |
| 990 |
\fi% |
| 991 |
\ifnum\texd@mon=4% |
| 992 |
\global\texd@dom=30% |
| 993 |
\fi% |
| 994 |
\ifnum\texd@mon=3% |
| 995 |
\global\texd@dom=29% |
| 996 |
\fi% |
| 997 |
\ifnum\texd@mon=2% |
| 998 |
\global\texd@dom=30% |
| 999 |
\fi% |
| 1000 |
\ifnum\texd@mon=1% |
| 1001 |
\ifnum\texd@leapyear=0% |
| 1002 |
\global\texd@dom=27% |
| 1003 |
\else\ifnum\texd@leapyear=1% |
| 1004 |
\global\texd@dom=28% |
| 1005 |
\fi\fi% |
| 1006 |
\fi% |
| 1007 |
\ifnum\texd@mon=0% |
| 1008 |
\global\texd@dom=30% |
| 1009 |
\fi% |
| 1010 |
\fi% |
| 1011 |
\global\texd@rdom=\texd@dom\global\advance\texd@rdom by1% |
| 1012 |
\global\texd@rmon=\texd@mon\global\advance\texd@rmon by1% |
| 1013 |
\texd@setjnum% |
| 1014 |
\texd@nextdow{\the\texd@rdom}{\the\texd@rmon}{\the\texd@yr}% |
| 1015 |
}% |
| 1016 |
\def\texd@setrdom{\global\texd@rdom=\texd@dom\global\advance\texd@rdom by1}% |
| 1017 |
\def\texd@setrmon{\global\texd@rmon=\texd@mon\global\advance\texd@rmon by1}% |
| 1018 |
% \end{macrocode} |
| 1019 |
% We have to deal with leap years somehow. We have the |
| 1020 |
% counter |\texd@leapyear|, which is 0 if it's not a leap |
| 1021 |
% year and 1 if it is. Then we have |\texd@isleapyear|, |
| 1022 |
% which sets the counter appropriately. |
| 1023 |
% \begin{macrocode} |
| 1024 |
\newcount\texd@leapyear\texd@leapyear=0% |
| 1025 |
\def\texd@isleapyear{% |
| 1026 |
\global\texd@leapyear=0% |
| 1027 |
\modulo{\texd@yr}{4}% |
| 1028 |
\ifnum\remainder=0% |
| 1029 |
\modulo{\texd@yr}{100}% |
| 1030 |
\ifnum\remainder=0% |
| 1031 |
\global\texd@leapyear=0% |
| 1032 |
\fi\ifnum\remainder>0% |
| 1033 |
\global\texd@leapyear=1% |
| 1034 |
\fi% |
| 1035 |
\fi% |
| 1036 |
}% |
| 1037 |
% \end{macrocode} |
| 1038 |
% Print the month names. |
| 1039 |
% \begin{macrocode} |
| 1040 |
\def\texd@monthname{% |
| 1041 |
\ifnum\texd@mon=0% |
| 1042 |
\texd@firstmon% |
| 1043 |
\fi% |
| 1044 |
\ifnum\texd@mon=1% |
| 1045 |
\texd@secondmon% |
| 1046 |
\fi% |
| 1047 |
\ifnum\texd@mon=2% |
| 1048 |
\texd@thirdmon% |
| 1049 |
\fi% |
| 1050 |
\ifnum\texd@mon=3% |
| 1051 |
\texd@fourthmon% |
| 1052 |
\fi% |
| 1053 |
\ifnum\texd@mon=4% |
| 1054 |
\texd@fifthmon% |
| 1055 |
\fi% |
| 1056 |
\ifnum\texd@mon=5% |
| 1057 |
\texd@sixthmon% |
| 1058 |
\fi% |
| 1059 |
\ifnum\texd@mon=6% |
| 1060 |
\texd@seventhmon% |
| 1061 |
\fi% |
| 1062 |
\ifnum\texd@mon=7% |
| 1063 |
\texd@eighthmon% |
| 1064 |
\fi% |
| 1065 |
\ifnum\texd@mon=8% |
| 1066 |
\texd@ninthmon% |
| 1067 |
\fi% |
| 1068 |
\ifnum\texd@mon=9% |
| 1069 |
\texd@tenthmon% |
| 1070 |
\fi% |
| 1071 |
\ifnum\texd@mon=10% |
| 1072 |
\texd@eleventhmon% |
| 1073 |
\fi% |
| 1074 |
\ifnum\texd@mon=11% |
| 1075 |
\texd@twelfthmon% |
| 1076 |
\fi% |
| 1077 |
}% |
| 1078 |
\def\texd@shmonthname{% |
| 1079 |
\ifnum\texd@mon=0% |
| 1080 |
\texd@firstshmon% |
| 1081 |
\fi% |
| 1082 |
\ifnum\texd@mon=1% |
| 1083 |
\texd@secondshmon% |
| 1084 |
\fi% |
| 1085 |
\ifnum\texd@mon=2% |
| 1086 |
\texd@thirdshmon% |
| 1087 |
\fi% |
| 1088 |
\ifnum\texd@mon=3% |
| 1089 |
\texd@fourthshmon% |
| 1090 |
\fi% |
| 1091 |
\ifnum\texd@mon=4% |
| 1092 |
\texd@fifthshmon% |
| 1093 |
\fi% |
| 1094 |
\ifnum\texd@mon=5% |
| 1095 |
\texd@sixthshmon% |
| 1096 |
\fi% |
| 1097 |
\ifnum\texd@mon=6% |
| 1098 |
\texd@seventhshmon% |
| 1099 |
\fi% |
| 1100 |
\ifnum\texd@mon=7% |
| 1101 |
\texd@eighthshmon% |
| 1102 |
\fi% |
| 1103 |
\ifnum\texd@mon=8% |
| 1104 |
\texd@ninthshmon% |
| 1105 |
\fi% |
| 1106 |
\ifnum\texd@mon=9% |
| 1107 |
\texd@tenthshmon% |
| 1108 |
\fi% |
| 1109 |
\ifnum\texd@mon=10% |
| 1110 |
\texd@eleventhshmon% |
| 1111 |
\fi% |
| 1112 |
\ifnum\texd@mon=11% |
| 1113 |
\texd@twelfthshmon% |
| 1114 |
\fi% |
| 1115 |
}% |
| 1116 |
% \end{macrocode} |
| 1117 |
% Here we define the |\advanceby|s, so that you can add move |
| 1118 |
% the internal date forward by a given number of units. Does |
| 1119 |
% \emph{not} print the date. |
| 1120 |
% \begin{macrocode} |
| 1121 |
\def\advancebydays#1{% |
| 1122 |
\texd@loopi=0% |
| 1123 |
\loop% |
| 1124 |
\ifnum\texd@loopi<#1% |
| 1125 |
\texd@nextdate% |
| 1126 |
\advance\texd@loopi by1% |
| 1127 |
\repeat% |
| 1128 |
}% |
| 1129 |
\def\regressbydays#1{% |
| 1130 |
\texd@loopi=0% |
| 1131 |
\loop% |
| 1132 |
\ifnum\texd@loopi<#1% |
| 1133 |
\texd@lastdate% |
| 1134 |
\advance\texd@loopi by1% |
| 1135 |
\repeat% |
| 1136 |
}% |
| 1137 |
\newcount\texd@loopj% |
| 1138 |
\def\advancebyweeks#1{% |
| 1139 |
\texd@loopi=0% |
| 1140 |
\texd@loopj=#1% |
| 1141 |
\multiply\texd@loopj by7% |
| 1142 |
\loop% |
| 1143 |
\ifnum\texd@loopi<\texd@loopj% |
| 1144 |
\texd@nextdate% |
| 1145 |
\advance\texd@loopi by1% |
| 1146 |
\repeat% |
| 1147 |
}% |
| 1148 |
\def\regressbyweeks#1{% |
| 1149 |
\texd@loopi=0% |
| 1150 |
\texd@loopj=#1% |
| 1151 |
\multiply\texd@loopj by7% |
| 1152 |
\loop% |
| 1153 |
\ifnum\texd@loopi<\texd@loopj% |
| 1154 |
\texd@lastdate% |
| 1155 |
\advance\texd@loopi by1% |
| 1156 |
\repeat% |
| 1157 |
}% |
| 1158 |
\def\advancebymonths#1{% |
| 1159 |
\texd@loopi=0% |
| 1160 |
\loop% |
| 1161 |
\ifnum\texd@loopi<#1% |
| 1162 |
\texd@nextmonth% |
| 1163 |
\advance\texd@loopi by1% |
| 1164 |
\repeat% |
| 1165 |
\texd@setrmon% |
| 1166 |
\initdate{\the\texd@yr}{\the\texd@rmon}{\the\texd@rdom}% |
| 1167 |
}% |
| 1168 |
\def\regressbymonths#1{% |
| 1169 |
\texd@loopi=0% |
| 1170 |
\loop% |
| 1171 |
\ifnum\texd@loopi<#1% |
| 1172 |
\texd@lastmonth% |
| 1173 |
\advance\texd@loopi by1% |
| 1174 |
\repeat% |
| 1175 |
\texd@setrmon% |
| 1176 |
\initdate{\the\texd@yr}{\the\texd@rmon}{\the\texd@rdom}% |
| 1177 |
}% |
| 1178 |
% \end{macrocode} |
| 1179 |
% Print the date, either with the default format or a named |
| 1180 |
% format. |
| 1181 |
% \begin{macrocode} |
| 1182 |
\def\printdate{% |
| 1183 |
\texd@dateformat% |
| 1184 |
}% |
| 1185 |
\def\printfdate#1{% |
| 1186 |
\texd@formatdateformat{#1}% |
| 1187 |
}% |
| 1188 |
% \end{macrocode} |
| 1189 |
% This defines the date format. We need some helper macros |
| 1190 |
% to flip through each character one at a time. |
| 1191 |
% \begin{macrocode} |
| 1192 |
\def\texd@expandloop#1{% |
| 1193 |
\texd@xloop#1\relax |
| 1194 |
} |
| 1195 |
\def\texdatenumformat#1{#1} |
| 1196 |
\def\texd@xloop#1{% |
| 1197 |
\ifx\relax#1% |
| 1198 |
\else% |
| 1199 |
\ifx#1d% |
| 1200 |
\setpadnum{2}\setpadchar{0}% |
| 1201 |
\padnum{\texdatenumformat{\the\texd@rdom}}% |
| 1202 |
\else\ifx#1e% |
| 1203 |
\setpadnum{2}\setpadchar{\hskip1ex}% |
| 1204 |
\padnum{\texdatenumformat{\the\texd@rdom}}% |
| 1205 |
\else\ifx#1a% |
| 1206 |
\texd@shdowname% |
| 1207 |
\else\ifx#1A% |
| 1208 |
\texd@downame% |
| 1209 |
\else\ifx#1b% |
| 1210 |
\texd@shmonthname% |
| 1211 |
\else\ifx#1h% |
| 1212 |
\texd@shmonthname% |
| 1213 |
\else\ifx#1B% |
| 1214 |
\texd@monthname% |
| 1215 |
\else\ifx#1w% |
| 1216 |
\the\texd@dow% |
| 1217 |
\else\ifx#1u% |
| 1218 |
\ifnum\texd@dow>0\leavevmode\texdatenumformat{\the\texd@dow}\fi% |
| 1219 |
\ifnum\texd@dow=0 7\fi% |
| 1220 |
\else\ifx#1Y% |
| 1221 |
\setpadnum{2}\setpadchar{0}% |
| 1222 |
\padnum{\texdatenumformat{\the\texd@yr}}% |
| 1223 |
\else\ifx#1m% |
| 1224 |
\texd@setrmon% |
| 1225 |
\setpadnum{2}\setpadchar{0}% |
| 1226 |
\leavevmode\padnum{\texdatenumformat{\the\texd@rmon}}% |
| 1227 |
\else\ifx#1j% |
| 1228 |
\texd@setjnum% |
| 1229 |
\setpadnum{3}\setpadchar{0}% |
| 1230 |
\leavevmode\padnum{\texdatenumformat{\the\texd@jnum}}% |
| 1231 |
\else\ifx#1C% |
| 1232 |
\quotient{\texd@yr}{100}% |
| 1233 |
\leavevmode\texdatenumformat{\the\intquotient}% |
| 1234 |
\else\ifx#1y% |
| 1235 |
\modulo{\texd@yr}{100}% |
| 1236 |
\leavevmode\texdatenumformat{\the\remainder}% |
| 1237 |
\else\ifx#1U% |
| 1238 |
\quotient{\texd@jnum}{7} |
| 1239 |
\setpadnum{2}\setpadchar{0}% |
| 1240 |
\leavevmode\padnum{\texdatenumformat{\the\intquotient}}% |
| 1241 |
\else\ifx#1V% |
| 1242 |
\quotient{\texd@jnum}{7} |
| 1243 |
\ifnum\texd@dow>0\advance\intquotient by1\fi% |
| 1244 |
\setpadnum{2}\setpadchar{0}% |
| 1245 |
\leavevmode\padnum{\texdatenumformat{\the\intquotient}}% |
| 1246 |
\else\ifx#1W% |
| 1247 |
\quotient{\texd@jnum}{7} |
| 1248 |
\ifnum\texd@dow=0\advance\intquotient by-1\fi% |
| 1249 |
\setpadnum{2}\setpadchar{0}% |
| 1250 |
\leavevmode\padnum{\texdatenumformat{\the\intquotient}}% |
| 1251 |
\else% |
| 1252 |
#1% |
| 1253 |
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% |
| 1254 |
\expandafter\texd@xloop% |
| 1255 |
\fi% |
| 1256 |
}% |
| 1257 |
\def\texd@dateformat{% |
| 1258 |
\expandafter\expandafter\texd@expandloop{\setdateformat}% |
| 1259 |
}% |
| 1260 |
\def\texd@formatdateformat#1{% |
| 1261 |
\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\texd@expandloop{\csname texd@df#1\endcsname}% |
| 1262 |
}% |
| 1263 |
\def\setdateformat{A{ }(a),\ B\ (b){ }d,\ Y} |
| 1264 |
\def\nameddateformat#1#2{% |
| 1265 |
\expandafter\def\csname texd@df#1\endcsname{#2}% |
| 1266 |
}% |
| 1267 |
\nameddateformat{american}{B\ d,\ Y} |
| 1268 |
\nameddateformat{shamerican}{m/d/Y} |
| 1269 |
\nameddateformat{ISO}{Ymd} |
| 1270 |
\nameddateformat{ISOext}{Y-m-d} |
| 1271 |
\nameddateformat{shbritish}{d/m/Y} |
| 1272 |
\nameddateformat{shbritishdots}{d.m.Y} |
| 1273 |
\nameddateformat{british}{d\ B\ Y} |
| 1274 |
\nameddateformat{d}{d} |
| 1275 |
\nameddateformat{e}{e} |
| 1276 |
\nameddateformat{B}{B} |
| 1277 |
\nameddateformat{b}{b} |
| 1278 |
\nameddateformat{h}{h} |
| 1279 |
\nameddateformat{m}{m} |
| 1280 |
\nameddateformat{A}{A} |
| 1281 |
\nameddateformat{a}{a} |
| 1282 |
\nameddateformat{w}{w} |
| 1283 |
\nameddateformat{u}{u} |
| 1284 |
\nameddateformat{Y}{Y} |
| 1285 |
\nameddateformat{j}{j} |
| 1286 |
\nameddateformat{C}{C} |
| 1287 |
\nameddateformat{y}{y} |
| 1288 |
\nameddateformat{U}{U} |
| 1289 |
\nameddateformat{V}{V} |
| 1290 |
\nameddateformat{W}{W} |
| 1291 |
% \end{macrocode} |
| 1292 |
% Initialize the date to the current date, or to an |
| 1293 |
% arbitrary date, entered in the order year, month, and day |
| 1294 |
% of month. |
| 1295 |
% \begin{macrocode} |
| 1296 |
\def\initcurrdate{% |
| 1297 |
\global\texd@mon=\month% |
| 1298 |
\global\advance\texd@mon by-1% |
| 1299 |
\global\texd@dom=\day% |
| 1300 |
\global\advance\texd@dom by-1% |
| 1301 |
\global\texd@yr=\year% |
| 1302 |
\texd@isleapyear% |
| 1303 |
\texd@setrdom% |
| 1304 |
\texd@setrmon% |
| 1305 |
\texd@setjnum% |
| 1306 |
\texd@nextdow{\the\texd@rdom}{\the\texd@rmon}{\the\texd@yr}% |
| 1307 |
}% |
| 1308 |
\def\initdate#1#2#3{% |
| 1309 |
\global\texd@yr=#1% |
| 1310 |
\global\texd@mon=#2% |
| 1311 |
\global\advance\texd@mon by-1% |
| 1312 |
\global\texd@dom=#3% |
| 1313 |
\global\advance\texd@dom by-1% |
| 1314 |
\global\texd@setrdom% |
| 1315 |
\global\texd@setrmon% |
| 1316 |
\texd@setjnum% |
| 1317 |
\texd@isleapyear% |
| 1318 |
\texd@nextdow{\the\texd@rdom}{\the\texd@rmon}{\the\texd@yr}% |
| 1319 |
}% |
| 1320 |
% \end{macrocode} |
| 1321 |
% Now we define the macros for saving and restoring dates. |
| 1322 |
% \begin{macrocode} |
| 1323 |
\def\savedate#1{% |
| 1324 |
\expandafter\edef\csname savedate#1\endcsname{\initdate{\the\texd@yr}{\the\texd@rmon}{\the\texd@rdom}}% |
| 1325 |
}% |
| 1326 |
\def\restoredate#1{% |
| 1327 |
\csname savedate#1\endcsname% |
| 1328 |
}% |
| 1329 |
% \end{macrocode} |
| 1330 |
% Convenience macros. First, |\texdcal|. |
| 1331 |
% \begin{macrocode} |
| 1332 |
\newcount\texd@looptmp\texd@looptmp=0% |
| 1333 |
\def\texdcal#1#2{% |
| 1334 |
\global\texd@mon=#2% |
| 1335 |
\global\advance\texd@mon by-1% |
| 1336 |
\global\texd@yr=#1% |
| 1337 |
\global\texd@dom=0% |
| 1338 |
\texd@setrmon\texd@setrdom% |
| 1339 |
\initdate{\the\texd@yr}{\the\texd@rmon}{\the\texd@rdom}% |
| 1340 |
\def\setdateformat{B\ Y}% |
| 1341 |
\begin{tabular}{rrrrrrr} |
| 1342 |
\multicolumn{7}{c}{\printdate} \\ |
| 1343 |
\loop\ifnum\texd@dow>0\texd@lastdate\repeat% |
| 1344 |
\def\setdateformat{d}% |
| 1345 |
\ifnum\texd@dom>8 {} \fi\ifnum\texd@dom<8\leavevmode\printdate\fi& |
| 1346 |
\def\setdateformat{d}\advancebydays{1}% |
| 1347 |
\ifnum\texd@dom>8 {} \fi\ifnum\texd@dom<8\leavevmode\printdate\fi& |
| 1348 |
\def\setdateformat{d}\advancebydays{1}% |
| 1349 |
\ifnum\texd@dom>8 {} \fi\ifnum\texd@dom<8\leavevmode\printdate\fi& |
| 1350 |
\def\setdateformat{d}\advancebydays{1}% |
| 1351 |
\ifnum\texd@dom>8 {} \fi\ifnum\texd@dom<8\leavevmode\printdate\fi& |
| 1352 |
\def\setdateformat{d}\advancebydays{1}% |
| 1353 |
\ifnum\texd@dom>8 {} \fi\ifnum\texd@dom<8\leavevmode\printdate\fi& |
| 1354 |
\def\setdateformat{d}\advancebydays{1}% |
| 1355 |
\ifnum\texd@dom>8 {} \fi\ifnum\texd@dom<8\leavevmode\printdate\fi& |
| 1356 |
\def\setdateformat{d}\advancebydays{1}% |
| 1357 |
\ifnum\texd@dom>8 {} \fi\ifnum\texd@dom<8\leavevmode\printdate\fi\\ |
| 1358 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1359 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1360 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1361 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1362 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1363 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1364 |
\def\setdateformat{d}\advancebydays{1}\printdate \\ |
| 1365 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1366 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1367 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1368 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1369 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1370 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1371 |
\def\setdateformat{d}\advancebydays{1}\printdate \\ |
| 1372 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1373 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1374 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1375 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1376 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1377 |
\def\setdateformat{d}\advancebydays{1}\printdate & |
| 1378 |
\def\setdateformat{d}\advancebydays{1}\printdate \\ |
| 1379 |
\def\setdateformat{d}\advancebydays{1}% |
| 1380 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1381 |
\def\setdateformat{d}\advancebydays{1}% |
| 1382 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1383 |
\def\setdateformat{d}\advancebydays{1}% |
| 1384 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1385 |
\def\setdateformat{d}\advancebydays{1}% |
| 1386 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1387 |
\def\setdateformat{d}\advancebydays{1}% |
| 1388 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1389 |
\def\setdateformat{d}\advancebydays{1}% |
| 1390 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1391 |
\def\setdateformat{d}\advancebydays{1}% |
| 1392 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi\\ |
| 1393 |
\def\setdateformat{d}\advancebydays{1}% |
| 1394 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1395 |
\def\setdateformat{d}\advancebydays{1}% |
| 1396 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1397 |
\def\setdateformat{d}\advancebydays{1}% |
| 1398 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1399 |
\def\setdateformat{d}\advancebydays{1}% |
| 1400 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1401 |
\def\setdateformat{d}\advancebydays{1}% |
| 1402 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1403 |
\def\setdateformat{d}\advancebydays{1}% |
| 1404 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi& |
| 1405 |
\def\setdateformat{d}\advancebydays{1}% |
| 1406 |
\ifnum\texd@dom<14 {} \fi\ifnum\texd@dom>14\leavevmode\printdate\fi\\ |
| 1407 |
\end{tabular} |
| 1408 |
}% |
| 1409 |
\def\texdcalyear#1{% |
| 1410 |
\texd@yr=#1% |
| 1411 |
\texd@mon=0% |
| 1412 |
\texd@dom=0% |
| 1413 |
\texd@setrmon% |
| 1414 |
\texd@setrdom% |
| 1415 |
{\tabcolsep=3pt% |
| 1416 |
\begin{tabular}{ccc} |
| 1417 |
\texdcal{#1}{1} & \texdcal{#1}{2} & \texdcal{#1}{3} \\ |
| 1418 |
\texdcal{#1}{4} & \texdcal{#1}{5} & \texdcal{#1}{6} \\ |
| 1419 |
\texdcal{#1}{7} & \texdcal{#1}{8} & \texdcal{#1}{9} \\ |
| 1420 |
\texdcal{#1}{10} & \texdcal{#1}{11} & \texdcal{#1}{12} \\ |
| 1421 |
\end{tabular} |
| 1422 |
}% |
| 1423 |
}% |
| 1424 |
% \end{macrocode} |
| 1425 |
% Calculate the day of the year (|%j|). |
| 1426 |
% \begin{macrocode} |
| 1427 |
\newcount\texd@jnum\texd@jnum=0% |
| 1428 |
\def\texd@setjnum{% |
| 1429 |
\texd@jnum=0% |
| 1430 |
\ifnum\texd@mon>0\global\advance\texd@jnum by31\fi% |
| 1431 |
\ifnum\texd@mon>1% |
| 1432 |
\global\advance\texd@jnum by28% |
| 1433 |
\fi% |
| 1434 |
\ifnum\texd@mon>2\global\advance\texd@jnum by31\fi% |
| 1435 |
\ifnum\texd@mon>3\global\advance\texd@jnum by30\fi% |
| 1436 |
\ifnum\texd@mon>4\global\advance\texd@jnum by31\fi% |
| 1437 |
\ifnum\texd@mon>5\global\advance\texd@jnum by30\fi% |
| 1438 |
\ifnum\texd@mon>6\global\advance\texd@jnum by31\fi% |
| 1439 |
\ifnum\texd@mon>7\global\advance\texd@jnum by31\fi% |
| 1440 |
\ifnum\texd@mon>8\global\advance\texd@jnum by30\fi% |
| 1441 |
\ifnum\texd@mon>9\global\advance\texd@jnum by31\fi% |
| 1442 |
\ifnum\texd@mon>10\global\advance\texd@jnum by30\fi% |
| 1443 |
\global\advance\texd@jnum by\the\texd@dom% |
| 1444 |
\global\advance\texd@jnum by1% |
| 1445 |
}% |
| 1446 |
% \end{macrocode} |
| 1447 |
% Language strings. I've only got English here right now, but |
| 1448 |
% additiona languages would be trivial to add, either in a |
| 1449 |
% particular document, or in a separate package. |
| 1450 |
% \begin{macrocode} |
| 1451 |
\def\texd@firstmon{January}% |
| 1452 |
\def\texd@firstshmon{Jan}% |
| 1453 |
\def\texd@secondmon{February}% |
| 1454 |
\def\texd@secondshmon{Feb}% |
| 1455 |
\def\texd@thirdmon{March}% |
| 1456 |
\def\texd@thirdshmon{Mar}% |
| 1457 |
\def\texd@fourthmon{April}% |
| 1458 |
\def\texd@fourthshmon{Apr}% |
| 1459 |
\def\texd@fifthmon{May}% |
| 1460 |
\def\texd@fifthshmon{May}% |
| 1461 |
\def\texd@sixthmon{June}% |
| 1462 |
\def\texd@sixthshmon{Jun}% |
| 1463 |
\def\texd@seventhmon{July}% |
| 1464 |
\def\texd@seventhshmon{Jul}% |
| 1465 |
\def\texd@eighthmon{August}% |
| 1466 |
\def\texd@eighthshmon{Aug}% |
| 1467 |
\def\texd@ninthmon{September}% |
| 1468 |
\def\texd@ninthshmon{Sep}% |
| 1469 |
\def\texd@tenthmon{October}% |
| 1470 |
\def\texd@tenthshmon{Oct}% |
| 1471 |
\def\texd@eleventhmon{November}% |
| 1472 |
\def\texd@eleventhshmon{Nov}% |
| 1473 |
\def\texd@twelfthmon{December}% |
| 1474 |
\def\texd@twelfthshmon{Dec}% |
| 1475 |
\def\texd@firstdayname{Sunday}% |
| 1476 |
\def\texd@firstdayshname{Sun}% |
| 1477 |
\def\texd@seconddayname{Monday}% |
| 1478 |
\def\texd@seconddayshname{Mon}% |
| 1479 |
\def\texd@thirddayname{Tuesday}% |
| 1480 |
\def\texd@thirddayshname{Tue}% |
| 1481 |
\def\texd@fourthdayname{Wednesday}% |
| 1482 |
\def\texd@fourthdayshname{Wed}% |
| 1483 |
\def\texd@fifthdayname{Thursday}% |
| 1484 |
\def\texd@fifthdayshname{Thu}% |
| 1485 |
\def\texd@sixthdayname{Friday}% |
| 1486 |
\def\texd@sixthdayshname{Fri}% |
| 1487 |
\def\texd@seventhdayname{Saturday}% |
| 1488 |
\def\texd@seventhdayshname{Sat}% |
| 1489 |
\AtBeginDocument{% |
| 1490 |
\IfLanguageName{spanish}{% |
| 1491 |
\def\texd@firstmon{enero}% |
| 1492 |
\def\texd@firstshmon{ene}% |
| 1493 |
\def\texd@secondmon{febrero}% |
| 1494 |
\def\texd@secondshmon{feb}% |
| 1495 |
\def\texd@thirdmon{marzo}% |
| 1496 |
\def\texd@thirdshmon{mar}% |
| 1497 |
\def\texd@fourthmon{abril}% |
| 1498 |
\def\texd@fourthshmon{abr}% |
| 1499 |
\def\texd@fifthmon{mayo}% |
| 1500 |
\def\texd@fifthshmon{may}% |
| 1501 |
\def\texd@sixthmon{junio}% |
| 1502 |
\def\texd@sixthshmon{jun}% |
| 1503 |
\def\texd@seventhmon{julio}% |
| 1504 |
\def\texd@seventhshmon{jul}% |
| 1505 |
\def\texd@eighthmon{agosto}% |
| 1506 |
\def\texd@eighthshmon{ago}% |
| 1507 |
\def\texd@ninthmon{septiembre}% |
| 1508 |
\def\texd@ninthshmon{sep}% |
| 1509 |
\def\texd@tenthmon{octubre}% |
| 1510 |
\def\texd@tenthshmon{oct}% |
| 1511 |
\def\texd@eleventhmon{noviembre}% |
| 1512 |
\def\texd@eleventhshmon{nov}% |
| 1513 |
\def\texd@twelfthmon{diciembre}% |
| 1514 |
\def\texd@twelfthshmon{dic}% |
| 1515 |
\def\texd@firstdayname{domingo}% |
| 1516 |
\def\texd@firstdayshname{dom}% |
| 1517 |
\def\texd@seconddayname{lunes}% |
| 1518 |
\def\texd@seconddayshname{lun}% |
| 1519 |
\def\texd@thirddayname{martes}% |
| 1520 |
\def\texd@thirddayshname{mar}% |
| 1521 |
\def\texd@fourthdayname{miercoles}% |
| 1522 |
\def\texd@fourthdayshname{mie}% |
| 1523 |
\def\texd@fifthdayname{jueves}% |
| 1524 |
\def\texd@fifthdayshname{jue}% |
| 1525 |
\def\texd@sixthdayname{viernes}% |
| 1526 |
\def\texd@sixthdayshname{vie}% |
| 1527 |
\def\texd@seventhdayname{sabado}% |
| 1528 |
\def\texd@seventhdayshname{sab}% |
| 1529 |
}{}% |
| 1530 |
\IfLanguageName{french}{% |
| 1531 |
\def\texd@firstmon{janvier}% |
| 1532 |
\def\texd@firstshmon{janv}% |
| 1533 |
\def\texd@secondmon{février}% |
| 1534 |
\def\texd@secondshmon{févr}% |
| 1535 |
\def\texd@thirdmon{mars}% |
| 1536 |
\def\texd@thirdshmon{mars}% |
| 1537 |
\def\texd@fourthmon{avril}% |
| 1538 |
\def\texd@fourthshmon{avr}% |
| 1539 |
\def\texd@fifthmon{mai}% |
| 1540 |
\def\texd@fifthshmon{mai}% |
| 1541 |
\def\texd@sixthmon{juin}% |
| 1542 |
\def\texd@sixthshmon{juin}% |
| 1543 |
\def\texd@seventhmon{juil}% |
| 1544 |
\def\texd@seventhshmon{juil}% |
| 1545 |
\def\texd@eighthmon{août}% |
| 1546 |
\def\texd@eighthshmon{août}% |
| 1547 |
\def\texd@ninthmon{septembre}% |
| 1548 |
\def\texd@ninthshmon{sept}% |
| 1549 |
\def\texd@tenthmon{octobre}% |
| 1550 |
\def\texd@tenthshmon{oct}% |
| 1551 |
\def\texd@eleventhmon{novembre}% |
| 1552 |
\def\texd@eleventhshmon{nov}% |
| 1553 |
\def\texd@twelfthmon{décembre}% |
| 1554 |
\def\texd@twelfthshmon{déc}% |
| 1555 |
\def\texd@firstdayname{dimanche}% |
| 1556 |
\def\texd@firstdayshname{dim}% |
| 1557 |
\def\texd@seconddayname{lundi}% |
| 1558 |
\def\texd@seconddayshname{lun}% |
| 1559 |
\def\texd@thirddayname{mardi}% |
| 1560 |
\def\texd@thirddayshname{mar}% |
| 1561 |
\def\texd@fourthdayname{mercredi}% |
| 1562 |
\def\texd@fourthdayshname{mer}% |
| 1563 |
\def\texd@fifthdayname{jeudi}% |
| 1564 |
\def\texd@fifthdayshname{jeu}% |
| 1565 |
\def\texd@sixthdayname{vendredi}% |
| 1566 |
\def\texd@sixthdayshname{ven}% |
| 1567 |
\def\texd@seventhdayname{samedi}% |
| 1568 |
\def\texd@seventhdayshname{sam}% |
| 1569 |
}{}% |
| 1570 |
\IfLanguageName{german}{% |
| 1571 |
\def\texd@firstmon{Januar}% |
| 1572 |
\def\texd@firstshmon{Jan}% |
| 1573 |
\def\texd@secondmon{Februar}% |
| 1574 |
\def\texd@secondshmon{Feb}% |
| 1575 |
\def\texd@thirdmon{März}% |
| 1576 |
\def\texd@thirdshmon{März}% |
| 1577 |
\def\texd@fourthmon{April}% |
| 1578 |
\def\texd@fourthshmon{Apr}% |
| 1579 |
\def\texd@fifthmon{Mai}% |
| 1580 |
\def\texd@fifthshmon{Mai}% |
| 1581 |
\def\texd@sixthmon{Juni}% |
| 1582 |
\def\texd@sixthshmon{Juni}% |
| 1583 |
\def\texd@seventhmon{Juli}% |
| 1584 |
\def\texd@seventhshmon{Juli}% |
| 1585 |
\def\texd@eighthmon{August}% |
| 1586 |
\def\texd@eighthshmon{Aug}% |
| 1587 |
\def\texd@ninthmon{September}% |
| 1588 |
\def\texd@ninthshmon{Sept}% |
| 1589 |
\def\texd@tenthmon{Oktober}% |
| 1590 |
\def\texd@tenthshmon{Okt}% |
| 1591 |
\def\texd@eleventhmon{November}% |
| 1592 |
\def\texd@eleventhshmon{Nov}% |
| 1593 |
\def\texd@twelfthmon{Dezember}% |
| 1594 |
\def\texd@twelfthshmon{Dez}% |
| 1595 |
\def\texd@firstdayname{Sonntag}% |
| 1596 |
\def\texd@firstdayshname{So}% |
| 1597 |
\def\texd@seconddayname{Montag}% |
| 1598 |
\def\texd@seconddayshname{Mo}% |
| 1599 |
\def\texd@thirddayname{Dienstag}% |
| 1600 |
\def\texd@thirddayshname{Di}% |
| 1601 |
\def\texd@fourthdayname{Mittwoch}% |
| 1602 |
\def\texd@fourthdayshname{Mi}% |
| 1603 |
\def\texd@fifthdayname{Donnerstag}% |
| 1604 |
\def\texd@fifthdayshname{Do}% |
| 1605 |
\def\texd@sixthdayname{Freitag}% |
| 1606 |
\def\texd@sixthdayshname{Fr}% |
| 1607 |
\def\texd@seventhdayname{Samstag}% |
| 1608 |
\def\texd@seventhdayshname{Sa}% |
| 1609 |
}{}% |
| 1610 |
}% |
| 1611 |
% \end{macrocode} |
| 1612 |
% Happy \TeX{}ing! |