The KOMA-timedate-bundle^{∗}

Markus Kohm

1994/12/31

Abstract This bundle includes a package scrtime defining some macros to handle compilation-time. It’s a very simple implementation similar to time.sty. I’ve tried to use no additional register.

The second package scrdate defines some macros to handle the name of the day!

Contents

1 Introduction 1 1.1 scrtime-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 scrdate-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Implementation 2 2.1 Time-macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2 Date-macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1 Introduction

1.1 scrtime-package

\today

\date {today’s-value} \thistime [hourseparator] \settime {thistime’s-value}

At L^{A}TEX there’s a macro \today to get compilation-date. There’s a macro \date to set the value of \today, too. But to handle compilation-time there ist only a macro \time which shows the gone minutes of the day.

With the macro \thistime you get the actual time. The optional argument [hourseparator] is used to separate hours and minutes. Default-value ist “:”.

With the macro \settime you may set the value of \thistime. After this the optional argument of \thistime will be ignored.

∗This file has version number v1.0a, last revised 1994/12/31.

1.2 scrdate-package

At L^{A}TEX there are macros to get the actual day or month or year. Using \today you even may get the name of the month, but you will never get the name of the day.

This package defines some macros to handle the name of the day.

Important: If you use language-packages like german or babel, these must be loaded after scrdate-package. Otherwise the name of the day’ll be wrong!

scrdate knows four languages:

• english

• USenglish

• german

• french

You may add additional languages using the configurationfile scrdate.cfg. There you have to define a macro \dayname@language. This macro has to be something like this:

\newcommand\dayname@language[1]{%
 \begingroup%
  \@tempcnta #1%
  \ifcase\@tempcnta%

Monday\or Tuesday\or Wednesday\or% Thursday\or Friday\or Saturday\or%

    Sunday\fi\endgroup%
}

Also you have to redefine \datelanguage like this:

  \let\D@datelanguage=\datelanguage
    \def\datelanguage {\let\@dayname=\dayname@language \D@datelanguage}%

\newdaylanguage {language}{Monday}{Tuesday}{Wednesday}{Thursday}{Friday}{Saturday}{Sunday}

defines the daynames of a language like shown before.

\todaysname

shows the name of the actual day (defined by \year, \month and \day or by \dayname).

\dayname {Name}

sets the name of the day to {Name}.

2 Implementation

2.1 Time-macros

1 ⟨∗scrtime⟩

We use \@tempcnta and \@tempcntb but we know, that this is not a very good idea.

\thistime First we have to calculate the hours and minutes. \@tempcnta are the hours and \@tempcntb are the minutes.

 2 \def\thistime{\@ifnextchar[{\@thistime}{\@thistime[:]}}
 3 \def\@thistime[#1]{%
 4 \begingroup
 5  \@tempcnta\time\divide\@tempcnta60\multiply\@tempcnta60%
 6  \@tempcntb\time\advance\@tempcntb-\@tempcntb%
 7  \divide\@tempcnta60%

Know we have to compose the value. If minutes less than 10 there has to be an additional 0.

 8  \the\@tempcnta{#1}\ifnum\@tempcntb<10 0\fi\the\@tempcntb%
 9 \endgroup}

\settime We simply have to set \thistime.

That’s it: 10 ⟨/scrtime⟩

2.2 Date-macros

11 ⟨∗scrdate⟩

To handle them, we need counters. We use same as in scrtime.

\todaysname This is not so easy. First we have to calculate how many days they are from 1st January 1980.

12 \newcommand\todaysname{%
13 \begingroup%
14 \@tempcnta\year\@tempcntb0%
15 \ifnum\@tempcnta<1980 unknown\else%
16  \advance\@tempcnta-1980%
17  \@whilenum\@tempcnta>=4\do%
18  {\advance\@tempcntb5\advance\@tempcnta-4}%
19  \ifnum\@tempcnta>0%
20  \ifnum\month>2\advance\@tempcntb1\fi%
21  \else%
22  \advance\@tempcntb\@tempcnta%
23  fi%
24  \ifcase\month\or\or\advance\@tempcntb3%  Jan =  28 + 3
25  \or\advance\@tempcntb3% +Feb =  56 + 3
26  \or\advance\@tempcntb6% +Mar =  84 + 6
27  \or\advance\@tempcntb1% +Apr = 119 + 1
28  \or\advance\@tempcntb4% +May = 147 + 4
29  \or\advance\@tempcntb6% +Jun = 175 + 6
30  \or\advance\@tempcntb2% +Jul = 210 + 2

31  \or\advance\@tempcntb5% +Aug = 238 + 5
32  \or%                    +Sep = 273 + 0
33  \or\advance\@tempcntb3% +Oct = 301 + 3
34  \or\advance\@tempcntb5% +Nov = 329 + 5
35  \fi%
36  \advance\@tempcntb\day%
37  \advance\@tempcntb5% 0 is Monday!
38  \@whilenum\@tempcntb>=7\do%
39  {\advance\@tempcntb-7}%

Now we can say which day it is.

40  \@dayname{\@tempcntb}%
41 \fi\endgroup}

\nameday We simply have to redefine \todaysname

42 \newcommand\nameday[1]{\renewcommand\todaysname{#1}}

\@dayname This should be named selecting the language. So we do some changes at \begin{document} (and hope, german.sty or other will be loaded after scrdate).

43 \AtBeginDocument{%
44 \let\D@dategerman=\dategerman%
45  \def\dategerman{\let\@dayname=\dayname@german\D@dategerman}%
46 \let\D@dateenglish=\dateenglish%
47  \def\dateenglish{\let\@dayname=\dayname@english\D@dateenglish}%
48 \let\D@dateUSenglish=\dateUSenglish%
49  \def\dateUSenglish{\let\@dayname=\dayname@english\D@dateUSenglish}%
50 \let\D@datefrench=\datefrench%
51  \def\datefrench{\let\@dayname=\dayname@french\D@datefrench}
52 \ifcase\language
53  \dateUSenglish
54 \or
55  \dategerman
56 \or
57  \datefrench
58 \fi

59 }

\dayname@german And here are the german daynames.

60 \newcommand\dayname@german[1]{%
61 \begingroup%
62 \@tempcnta #1%
63 \ifcase\@tempcnta%
64  Montag\or Dienstag\or Mittwoch\or Donnerstag\or%
65  Freitag\or Samstag\or Sonntag\fi\endgroup%

66 }

\dayname@english And the english daynames

67 \newcommand\dayname@english[1]{%

68 \begingroup%
69 \@tempcnta #1%
70 \ifcase\@tempcnta%
71  Monday\or Tuesday\or Wednesday\or Thursday\or%
72  Friday\or Saturday\or Sunday\fi\endgroup%

73 }

\dayname@french And the french daynames

74 \newcommand\dayname@french[1]{%
75 \begingroup%
76 \@tempcnta #1%
77 \ifcase\@tempcnta%
78  Lundi\or Mardi\or Mercredi\or Jeudi\or%
79  Vendredi\or Samedi\or Dimanche\fi\endgroup%

80 }

\newdaylanguage We only have to define like before.

81 \newcommand\newdaylanguage[8]{%

First we define the new macro \dayname@language:

82 \expandafter\def\csname dayname@#1\endcsname{%
83  \begingroup%
84  \@tempcnta #1%
85  \ifcase\@tempcnta%
86  #2\or #3\or #4\or #5\or #6\or #7\or #8\fi\endgroup%

87 }

Then we define, what to do at \begin{document}:

88 \AtBeginDocument{

There we first save \datelanguage as \D@datelanguage:

89  \expandafter\let\csname D@date#1\endcsname=\csname date#1\endcsname

Now we redefine \datelanguage. It first defines \@dayname and then calls saved macro.

90  \expandafter\def\csname date#1\endcsname{%
91  \let\@dayname=\csname dayname@#1\endcsname\csname D@date#1\endcsname}%

Last we have to select this new \datelanguage, if the actual language is the new language. We do this using the german.sty-language-selection with \l@language:

92  \expandafter\ifx\csname l@#1\endcsname\relax
93  \else
94  \ifnum\language=\csname l@#1\endcsname
95  \csname date#1\endcsname
96  \fi
97  \fi

98 } 99 }

Last but not least file scrdate.cfg has to be included, if it exists.

100 \InputIfFileExists{scrdate.cfg}

101  {\typeout{*************************************^^J%
102  * Local config file scrdate.cfg used^^J%
103  *************************************}}

104 {}

That’s it: 105 ⟨/scrdate⟩