summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/datenumber/doc.tex
blob: 60d5351d66b7a7efcd58e2d372441239d17d3153 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
%%
%% This is file `docgerman.tex'.
%% 
%% This file is part of the `datenumber' package,
%% 
%% Copyright (C) 2001 J"org-Michael Schr"oder.
%% 
%% IMPORTANT NOTICE:
%% 
%% This program may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%% 
%% This program consists of all files listed in README.txt.
%% 
%% For error reports, or offers to help make this a more powerful
%% tool, please contact me on schrj020@mail.uni-mainz.de
%% 

\documentclass[draft]{article}
\usepackage{datenumber}

\oddsidemargin 0.25in
\textwidth 5.875 in
\addtolength{\textheight}{8\baselineskip}
\addtolength{\topmargin}{-5\baselineskip}

\title{The {\tt datenumber.sty} package \fileversion}

\author{J\"org-Michael Schr\"oder\\{\small\texttt{schrj020@mail.uni-mainz.de}}}

\date{\filedate}

\newcounter{dateone}\newcounter{datetwo}%
\newcommand{\daydifftoday}[3]{%
  \setmydatenumber{dateone}{\the\year}{\the\month}{\the\day}%
  \setmydatenumber{datetwo}{#1}{#2}{#3}%
  \addtocounter{datetwo}{-\thedateone}%
  \thedatetwo
}

\newcommand{\sd}{%
\ifcase\thedatedayname \or
    Mon\or Tue\or Wed\or Thu\or
    Fri\or Sat\or Sun\fi
}%

\newcommand{\pnext}{%
\thedateyear/%
\ifnum\value{datemonth}<10 0\fi
\thedatemonth/%
\ifnum\value{dateday}<10 0\fi
\thedateday%
\nextdate
}

\begin{document}
\maketitle
\begin{abstract}

This package provides commands to convert a date into a number. Turned around a date can be calculated also by a number. Additionally there are commands for incrementing and decrementing a date. Leap years and the Gregorian calendar reform are considered.
\end{abstract}

\tableofcontents
\section{Start year}
The start of the counting is determined with \verb+\setstartyear{year}+ (standard 1800). The first day of the start year gets the number 1. The value of \texttt{startyear} must be greater 0. It may not be larger than the year of a date to be calculated. If the difference of date and \texttt{startyear} is large, the calculation can last for a long time. The correct setting of the weekdays is guaranteed only if the value of \texttt{startyear} is 1800, 1900 or 2000.
\section{Counters}
There are five counters defined
\begin{description}
\item[\texttt{datenumber}:] number of the day
\item[\texttt{dateyear}:] year
\item[\texttt{datemonth}:] month
\item[\texttt{dateday}:] day
\item[\texttt{datedayname}:] weekday: 1--7 (Monday--Sunday)
\end{description}
\section{Macros}
\subsection{Macros which operate with defined counters\label{macro}}
All counters specified above are updated by these macros. \verb+\datedayname+ and \verb+\datemonthname+ are also updated.
\begin{description}
\item[\texttt{\textbackslash setdatenumber\{year\}\{month\}\{day\}}:] Sets the counter \texttt{datenumber} to a value, which corresponds to the date.
\item[\texttt{\textbackslash setdatebynumber\{number\}}:] Sets the counters \texttt{dateyear}, \texttt{datemonth}, and \texttt{dateday} to values, which corresponds to the number.
\item[\texttt{\textbackslash nextdate}:] Sets the counters \texttt{dateyear}, \texttt{datemonth}, and \texttt{dateday} to the next date.
\item[\texttt{\textbackslash prevdate}:] Sets the counters \texttt{dateyear}, \texttt{datemonth}, and \texttt{dateday} to the previous date.
\item[\texttt{\textbackslash setdate\{year\}\{month\}\{day\}}:] Sets the counters \texttt{dateyear}, \texttt{datemonth}, and \texttt{dateday} to \texttt{year}, \texttt{month}, and \texttt{day}.
\item[\texttt{\textbackslash setdatetoday}:] Sets the counters \texttt{dateyear}, \texttt{datemonth}, and \texttt{dateday} to the current date.
\item[\texttt{\textbackslash datemonthname}:] typesets the month (see section \ref{monthname}).
\item[\texttt{\textbackslash datedayname}:] typesets the weekday (see section \ref{dayname}).
\item[\texttt{\textbackslash datedate}:] typesets the date, corresponding to the counters \texttt{dateyear}, \texttt{datemonth}, \texttt{dateday}.
\end{description}
\subsection{Macros which operate with your own counters}
Only the counters you specified are updated by these macros. \verb+\datedayname+ and \verb+\datemonthname+ are not updated.
\begin{description}\sloppypar
\item[\texttt{\textbackslash setmydatenumber\{numbercount\}\{year\}\{month\}\{day\}}:] Sets the counter \texttt{numbercount} to a value, which corresponds to the date.
\item[\texttt{\textbackslash setmydatebynumber\{number\}\{yearcount\}\{monthcount\}\{daycount\}}:] Sets the counters \texttt{yearcount}, \texttt{monthcount}, and \texttt{daycount} to values, which corresponds to the number.
\item[\texttt{\textbackslash mynextdate\{yearcount\}\{monthcount\}\{daycount\}}:] Sets the counters \texttt{yearcount}, \texttt{monthcount}, and \texttt{daycount} to the next date.
\item[\texttt{\textbackslash mynextdate\{yearcount\}\{monthcount\}\{daycount\}}:]Sets the counters \texttt{yearcount}, \texttt{monthcount}, and \texttt{daycount} to the previous date.
\end{description}

\subsection{Month\label{monthname}}
The command \verb+\datemonthname+ typesets the month. It is updated by macros described in section \ref{macro}. You can do this by your own saying \verb+\setmonthname{number}+.

\subsection{Weekday\label{dayname}}
To typeset the weekday say \verb+\datedayname+. This command is updated by macros described in section \ref{macro}.
You can do this by your own saying \verb+\setmonthname{number}+ (1 for Monday and 7 for Sunday). You can also write \verb+\setdaynamebynumber{number}+, were \verb+number+ is the number of a date. If \texttt{startyear} is set to 1800, 1900 or 2000 the calculation of the weekday will work.

\section{Language}\sloppypar
The language options \texttt{english}, \texttt{USenglish} (standard), \texttt{french}, \texttt{spanish}, \texttt{german}, and \texttt{ngerman} are supported. Say \verb+\dateselectlanguage{language}+ to select a language. For other languages: Create a file \texttt{datenumbermylanguage.ldf}. Copy the text from \texttt{datenumberdummy.ldf}. Replace every ``dummy'' with ``mylanguage'' and change the months and weekdays. Say \verb+\usepackage{datenumber}+ \verb+\input{datenumbermylanguage.ldf}+ in your document.

\section{Examples}
\begin{quote}
\begin{verbatim}
\setdate{2002}{1}{1}%
\thedatenumber
\end{verbatim}
\setdate{2002}{1}{1}%
Result: \thedatenumber
\end{quote}

\begin{quote}
\begin{verbatim}
\setdatetoday
\addtocounter{datenumber}{10}%
\setdatebynumber{\thedatenumber}%
In 10 days is \datedate
\end{verbatim}
\setdatetoday
\addtocounter{datenumber}{10}%
\setdatebynumber{\thedatenumber}%
Result: In 10 days is \datedate
\end{quote}

\begin{quote}
\begin{verbatim}
\newcounter{dateone}\newcounter{datetwo}%

\newcommand{\daydifftoday}[3]{%
  \setmydatenumber{dateone}{\the\year}{\the\month}{\the\day}%
  \setmydatenumber{datetwo}{#1}{#2}{#3}%
  \addtocounter{datetwo}{-\thedateone}%
  \thedatetwo
}

There is still \daydifftoday{\the\year}{12}{25} days to Christmas.
\end{verbatim}
Result: There is still \daydifftoday{\the\year}{12}{25} days to Christmas.
\end{quote}

\clearpage
\begin{quote}
\begin{verbatim}
\newcommand{\sd}{%
\ifcase\thedatedayname \or
    Mon\or Tue\or Wed\or Thu\or
    Fri\or Sat\or Sun\fi
}%

\newcommand{\pnext}{%
\thedateyear/%
\ifnum\value{datemonth}<10 0\fi
\thedatemonth/%
\ifnum\value{dateday}<10 0\fi
\thedateday%
\nextdate
}

\setdate{2001}{9}{29}%
\[\begin{tabular}{lll}
\sd & \pnext & Abc\\
\sd & \pnext & Def\\
\sd & \pnext & Ghi\\
\sd & \pnext & Jkl\\
\end{tabular}\]
\end{verbatim}
Result: \setdate{2001}{9}{29}%
\[\begin{tabular}{lll}
\sd & \pnext & Abc\\
\sd & \pnext & Def\\
\sd & \pnext & Ghi\\
\sd & \pnext & Jkl\\
\end{tabular}\]
\end{quote}

\section{Other}
\begin{itemize}
\item leap year test
\begin{quote}
\begin{verbatim}
The \the\year\ is
\ifleapyear{\the\year} a \else no \fi leap year.
\end{verbatim}
Result: The \the\year\ is \ifleapyear{\the\year} a \else no \fi leap year.
\end{quote}
\item date test
\begin{quote}
\begin{verbatim}
The 29.2.1900 is
\ifvaliddate{1900}{2}{29} a \else no \fi valid date.
\end{verbatim}
Result: The 29.2.1900 is \ifvaliddate{1900}{2}{29} a \else no \fi valid date.%
\footnote{There are programs, which have another opinion about that. Search for ''Gregorian calendar'' in order to get more information about leap years and October 5, 1582}
\end{quote}
\end{itemize}

\end{document}
\endinput
%%
%% End of file `doc.tex'.