blob: ea504ba375ba677383c221828cdff366964e55ea (
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
|
%%%------------Start Cutting------------------------------------------
% \dowcomp returns integer day of week in \dow with Sunday=0.
% \downame returns the name of the day of the week.
% E.g., if \year=1963 \month=11 \day=22,
% then \dowcomp ==> \dow=5 and \downame ==> Friday which happened
% to be the day President John F. Kennedy was assasinated.
% Converted from the lisp function DOW by Jon L. White given in
% the file LIBDOC DOW JONL3 on MIT-MC (which follows).
%(defun dow (year month day)
% (and (and (fixp year) (fixp month) (fixp day))
% ((lambda (a)
% (declare (fixnum a))
% (\ (+ (// (1- (* 13. (+ month 10.
% (* (// (+ month 10.) -13.) 12.))))
% 5.)
% day
% 77.
% (// (* 5. (- a (* (// a 100.) 100.))) 4.)
% (// a -2000.)
% (// a 400.)
% (* (// a -100.) 2.))
% 7.))
% (+ year (// (+ month -14.) 12.)))))
\newcount\dow
\def\dowcomp{{\count3 \month \advance\count3 -14 \divide\count3 12
\advance\count3 \year \count4 \month \advance\count4 10
\divide\count4 -13 \multiply\count4 12 \advance\count4 10
\advance\count4 \month \multiply\count4 13 \advance\count4 -1
\divide\count4 5 \advance\count4 \day \advance\count4 77
\count2 \count3 \divide\count2 100 \multiply\count2 -100
\advance\count2 \count3 \multiply\count2 5 \divide\count2 4
\advance\count4 \count2 \count2 \count3 \divide\count2 -2000
\advance\count4 \count2 \count2 \count3 \divide\count2 400
\advance\count4 \count2 \count2 \count3 \divide\count2 -100
\multiply\count2 2 \advance\count4 \count2 \count2 \count4
\divide\count2 7 \multiply\count2 -7 \advance\count4 \count2
\global\dow \count4}}
\def\dayname{\dowcomp \ifcase\dow Sunday\or Monday\or Tuesday\or
Wednesday\or Thursday\or Friday\else Saturday\fi}
%%%--------------Stop cutting-----------------------------------------
|