Debian Codegraph @

texmf-dist/source/latex/eukdate/eukdate.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright Andrew Gilbert Moschou 2008
4 %
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3c
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.3c or later is part of all distributions of LaTeX
13 % version 2005/12/01 or later.
14 %
15 % \fi
16 %
17 % \iffalse
18 %<package>\NeedsTeXFormat{LaTeX2e}
19 %<package>\ProvidesPackage{eukdate}[2009/03/18 v1.04 UK format date (Hart's Rules) with weekday]
20 %
21 %<*driver>
22 \documentclass{ltxdoc}
23 \usepackage{eukdate}
24 \EnableCrossrefs
25 \CodelineIndex
26 \newcommand\US{\textsc{us}}
27 \newcommand\UK{\textsc{uk}}
28 \newcommand\floor[1]{\left\lfloor#1\right\rfloor}
29 \newcommand\pp[1]{\left(#1\right)}
30 \usepackage{amsmath}
31 \hyphenation{ori-gin-al-ly ca-len-dar}
32 \frenchspacing
33 \begin{document}
34 \DocInput{eukdate.dtx}
35 \end{document}
36 %</driver>
37 % \fi
38 %
39 % \CheckSum{163}
40 %
41 % \GetFileInfo{eukdate.sty}
42 %
43 % \DoNotIndex{\addtocounter}
44 % \DoNotIndex{\day,\DeclareOption,\def,\divide}
45 % \DoNotIndex{\edef,\else,\eukordinal,\ExecuteOptions}
46 % \DoNotIndex{\fi}
47 % \DoNotIndex{\ifcase,\ifnum}
48 % \DoNotIndex{\loop}
49 % \DoNotIndex{\month,\multiply}
50 % \DoNotIndex{\newcommand,\newcounter,\newif,\number}
51 % \DoNotIndex{\or}
52 % \DoNotIndex{\ProcessOptions}
53 % \DoNotIndex{\relax,\repeat}
54 % \DoNotIndex{\setcounter,\space}
55 % \DoNotIndex{\year}
56 %
57 % \title{The \textsf{eukdate} package}
58 % \author{Andrew Gilbert Moschou\\\textsf{[email protected]}}
59 % \makeatletter
60 % \date{\today\\v.~\expandafter\@gobble\fileversion}
61 % \makeatother
62 %
63 % \maketitle
64 %
65 % \section{Introduction}
66 %
67 % This package redefines \DescribeMacro{\today}|\today|, to typeset |\today|'s date in, the format \emph{Day, Date Month Year} (here, called `\UK\ format'), e.g., `\weekday, \number\day\ \monthname\ \number\year', as is preferred in many parts of the world outside the \US. Thus, |\maketitle| uses the \UK\ format (instead of the default \US\ format, e.g. \monthname\ \number\day, \number\year, as used in the |article| class).
68 %
69 % From \emph{Hart's Rules} (Hart, H., 1983. \emph{Hart's Rules for Compositors and Readers at the University Press Oxford}, Thirty-ninth edition, Completely revised, Originally compiled by Horace Hart, \textsc{m.a.}, Printer to the University, 1883--1915, Oxford University Press, Oxford, pp.~18--19.):
70 %
71 % \makeatletter\begin{center}\begin{minipage}[t]{100mm}
72 % \def\thempfootnote{{\@arabic\c@mpfootnote}}
73 % In dates, print 25 June 1978.\footnote{~This will not apply to quotations, nor to reprints of documents. As to the form May 19, 1862, Sir James Murray said, `This is not logical: 19 May 1862 is. \emph{Begin} at day, \emph{ascend} to month, \emph{ascend} to year; not \emph{begin} at month, \emph{descend} to day, then \emph{ascend} to year.'} Omit comma between month and year: `The delay after November 1967 was due to an oversight.'
74 % \end{minipage}\end{center}\makeatother
75 %
76 % This package also determines |\today|'s day of the week, which still makes the package useful even to Americans who might use the |usdate| option. The day of the week is calculated according to Zeller's congruence:
77 % \begin{align*}w &= \begin{cases}
78 % d + \floor{\frac{26}{10}\pp{m+1}} + y + \floor{\frac{y}{4}} + \floor{\frac{c}{4}} - 2c\pmod 7 & \mbox{Gregorian calendar}\\
79 % d + \floor{\frac{26}{10}\pp{m+1}} + y + \floor{\frac{y}{4}} + 5 - c\pmod 7 & \mbox{Julian calendar}
80 % \end{cases}\end{align*}where $d$ is the day of the month, $m$ is the number of the month, $y$ is the two digit year, $c$ is the century (so the four digit year is given by $100c+y$) and $w$ represents the day of the week (0 for Saturday through to 6 for Friday); January and February are counted as months 13 and 14 of the previous year.
81 %
82 % \makeatletter
83 % The ordinal indicator of the date (in e.g. \number\day\textsuperscript{\euk@ordinal}, \number\day\euk@ordinal) is absent because its use is outdated.
84 % \makeatother
85 %
86 % \section{Usage}
87 %
88 % The package is invoked with |\usepackage{eukdate}|. This package also defines \DescribeMacro{\weekday}|\weekday| to typeset |\today|'s day of the week and \DescribeMacro{\monthname}|\monthname| to typeset the name of |\today|'s month (`\weekday' and `\monthname' when this document was typeset).
89 %
90 % \subsection{Options}
91 %
92 % \begin{description}
93 % \item[\sffamily no-weekday]Suppresses the weekday when typesetting |\today|, for example, `\number\day\ \monthname\ \number\year'. |\weekday| is still defined and can be used in the document.
94 % \item[\sffamily ukdate]Typesets |\today| in \UK\ format, `\weekday, \number\day\ \monthname\ \number\year'. This option is applied by default, if the |usdate| option is not specified.
95 % \item[\sffamily usdate]Typesets |\today| in \US\ format, `\weekday, \monthname\ \number\day, \number\year'.
96 % \item[\sffamily gregorian]Calculates the day of the week according to the Gregorian calendar, which is the calendar that is generally used today. This option is applied by default, if the |julian| option is not specified.
97 % \item[\sffamily julian]Calculates the day of the week according to the Julian calendar. However, since |\today|'s date is not \emph{today}'s date, as intepreted using the Julian calendar, this option is of limited use and can be safely ignored for every day use.
98 % \end{description}
99 %
100 % \section{Why a new solution?}
101 %
102 % It is natural to ask `Why a new solution to this problem?' because surely, somebody has already dealt with the issue. This is true but other solutions tend to be cumbersome. A similar effect can be achieved with |\usepackage[australian]{babel}| or |\usepackage[english,cleanlook]{isodate}|, but these instances do not include the day of the week. The day of the week can be calculated separately with scripts like |dow| or |dayofweek|, but neither is automatically integrated into the definition of |\today|. The |datetime| package can do this with the |\longdate| command, but there are minor format issues, which can be fixed only by defining a new format.
103 %
104 % This package was created to offer a simple method to set the date using a format according to \emph{my} preferences in a way that is portable to each system. It supports only a handful of date formats and in no way aims to be comprehensive.
105 %
106 % \StopEventually{\PrintIndex}
107 % \section{\textsf{eukdate.sty}}
108 % \begin{macrocode}
109 \newif\if@euk@noweekday
110 \newif\if@euk@usdate
111 \newif\if@euk@julian
112 \DeclareOption{no-weekday}{\@euk@noweekdaytrue}
113 \DeclareOption{ukdate}{\@euk@usdatefalse}
114 \DeclareOption{usdate}{\@euk@usdatetrue}
115 \DeclareOption{gregorian}{\@euk@julianfalse}
116 \DeclareOption{julian}{\@euk@juliantrue}
117 \ExecuteOptions{ukdate,gregorian}
118 \ProcessOptions\relax
119 % \end{macrocode}
120 % \subsection{Zeller's congruence}
121 % Actually, the equivalent congruence:\begin{align*}w &= \begin{cases}
122 % d + \floor{\frac{26}{10}\pp{m+1}} + y + \floor{\frac{y}{4}} + \floor{\frac{c}{4}} + 5c\pmod 7 & \mbox{Gregorian calendar}\\
123 % d + \floor{\frac{26}{10}\pp{m+1}} + y + \floor{\frac{y}{4}} + 5 + 6c\pmod 7 & \mbox{Julian calendar}
124 % \end{cases}\end{align*}is used instead of Zeller's, as claimed, to simplify the algorithm for the modulo operation.
125 % \begin{macrocode}
126 \newcounter{euk@date}
127 \newcounter{euk@month}
128 \newcounter{euk@century}
129 \newcounter{euk@year}
130 \setcounter{euk@date}{\number\day}
131 \setcounter{euk@month}{\number\month}
132 \setcounter{euk@century}{\number\year}
133 \divide\c@euk@century by 100
134 \setcounter{euk@year}{\number\year}
135 \addtocounter{euk@year}{-\theeuk@century00}
136 \ifnum\number\theeuk@month<3
137 \addtocounter{euk@month}{13}
138 \addtocounter{euk@year}{-1}
139 \else
140 \addtocounter{euk@month}{1}
141 \fi
142 \multiply\c@euk@month by 26
143 \divide\c@euk@month by 10
144 \addtocounter{euk@date}{\theeuk@month}
145 \addtocounter{euk@date}{\theeuk@year}
146 \divide\c@euk@year by 4
147 \addtocounter{euk@date}{\theeuk@year}
148 \if@euk@julian
149 \addtocounter{euk@date}{6\theeuk@century}
150 \addtocounter{euk@date}{5}
151 \else
152 \addtocounter{euk@date}{5\theeuk@century}
153 \divide\c@euk@century by 4
154 \addtocounter{euk@date}{\theeuk@century}
155 \fi
156 % \end{macrocode}
157 % The modulo operation.
158 % \begin{macrocode}
159 \loop\ifnum6<\theeuk@date
160 \addtocounter{euk@date}{-7}
161 \repeat
162 % \end{macrocode}
163 % \subsection{Definitions}
164 % \begin{macro}{\weekday}
165 % Define |\weekday| to typeset the day of the week.
166 % \begin{macrocode}
167 \newcommand\weekday{%
168 \ifcase\theeuk@date Saturday\or Sunday\or Monday\or
169 Tuesday\or Wednesday\or Thursday\or Friday\fi}
170 % \end{macrocode}
171 % \end{macro}
172 % \begin{macro}{\monthname}
173 % Define |\monthname| to typeset the month.
174 % \begin{macrocode}
175 \newcommand\monthname{%
176 \ifcase\number\month\or January\or February\or March\or
177 April\or May\or June\or July\or August\or
178 September\or October\or November\or December\fi}
179 % \end{macrocode}
180 % \end{macro}
181 % \begin{macro}{\today}
182 % Redefine |\today|.
183 % \begin{macrocode}
184 \def\today{%
185 \if@euk@noweekday\else\weekday,\space\fi
186 \if@euk@usdate
187 \monthname\space\number\day,%
188 \else
189 \number\day\space\monthname
190 \fi
191 \space\number\year}
192 % \end{macrocode}
193 % \end{macro}
194 % An `undocumented' feature.
195 % \begin{macrocode}
196 \edef\euk@ordinal{%
197 \ifcase\number\day\or st\or nd\or rd\or th\or th\or
198 th\or th\or th\or th\or th\or th\or th\or th\or th\or
199 th\or th\or th\or th\or th\or th\or st\or nd\or rd\or
200 th\or th\or th\or th\or th\or th\or th\or st\fi}
201 % \end{macrocode}
202 % \Finale
203 \endinput