Почему \the\day не работает в моем макросе?

Почему \the\day не работает в моем макросе?

(TeX-код!)

Я определил TeX-макрос для сравнения значений даты и времени. Все работает хорошо, пока я не вставляю \the\day, чтобы вызвать его текущее значение. Может кто-нибудь представить, почему это работает со всеми функциями даты и времени, кроме \the\day?

    %transformations of \time
\newcount\hour  %
\newcount\hours  %
\newcount\minutes  %
\hour=\time \divide\hour by 60 
\minutes=\time
\hours=\hour \multiply\hours by 60 
\advance \minutes by -\hours
%end transformations of \time
%begin  definitions of caldate
\newcount\fromcalyear %% 
\newcount\fromcalmonth %%
\newcount\fromcalday %%
\newcount\fromcalhour %%
\newcount\fromcalminutes %%
\newcount\tocalyear %% 
\newcount\tocalmonth %%
\newcount\tocalday %%
\newcount\tocalhour %%
\newcount\tocalminutes %%
\newcount\rescalyear %% 
\newcount\rescalmonth %%
\newcount\rescalday %%
\newcount\rescalhour %%
\newcount\rescalminutes %%
\def\fromcaldate[#1-#2-#3 #4:#5]{%
\global\fromcalyear=#1 %
\global\fromcalmonth=#2 %
\global\fromcalday=#3 %
\global\fromcalhour=#4 %
\global\fromcalminutes=#5 %
\ \the\fromcalyear-\ifnum\fromcalmonth<10
0\fi\the\fromcalmonth-\ifnum\fromcalday<10
0\fi\the\fromcalday\ \ifnum\fromcalhour<10
0\fi\the\fromcalhour:\ifnum\fromcalminutes<10 0\fi\the\fromcalminutes
\vskip0.1\baselineskip}% 
\def\tocaldate[#1-#2-#3 #4:#5]{%
\global\tocalyear=#1 %
\global\tocalmonth=#2 %
\global\tocalday=#3 %
\global\tocalhour=#4 %
\global\tocalminutes=#5\ % 
\the\tocalyear-\ifnum\tocalmonth<10
0\fi\the\tocalmonth-\ifnum\tocalday<10
0\fi\the\tocalday\ \ifnum\tocalhour<10
0\fi\the\tocalhour:\ifnum\tocalminutes<10 0\fi\the\tocalminutes}
\def\rescaldate{
\global\rescalyear=\the\fromcalyear %
\global\rescalmonth=\fromcalmonth %
\global\rescalday=\fromcalday %
\global\rescalhour=\fromcalhour %
\global\rescalminutes=\fromcalminutes %
\advance\rescalyear by -\tocalyear %
\global\advance\rescalmonth by -\tocalmonth  %
\global\advance\rescalday by -\tocalday   %
\global\advance\rescalhour by -\tocalhour   %
\global\advance\rescalminutes by -\tocalminutes   %
\vskip0.1\baselineskip}% 
\def\rescaldatetime{\rescaldate (\the\rescalyear)-(\the\rescalmonth)-(\the\rescalday)\ (\the\rescalhour):(\the\rescalminutes)}
%end definitions of caldate
Here, the day is displayed: {\bf \the\day}
\vskip1\baselineskip
Below, it works without calling the day by function

From Date: \fromcaldate[\the\year-\the\month-11 \the\hour:\the\minutes]
To Date: \tocaldate[2012-11-05 04:16]

Res Date: \rescaldatetime
\vskip1\baselineskip

Below, it does not work with calling the day by function (outcommented)

%Fromdate: \fromcaldate[\the\year-\the\month-\the\day 13:00]
%Fromdate: \fromcaldate[\the\year-\the\month-\the\day \the\hour:\the\minutes]
%Todate: \tocaldate[\the\year-\the\month-\the\day \the\hour:\the\minutes]

%Resdate: \rescaldatetime

\bye

решение1

У вас есть

\def\tocaldate[#1-#2-#3 #4:#5]{%

поэтому после должен быть пробел#3

Fromdate: \fromcaldate[\the\year-\the\month-\the\day 13:00]

в приведенном выше примере пробел отсутствует, 13поскольку пространство в файле поглощается при токенизации \day.

Использовать

Fromdate: \fromcaldate[\the\year-\the\month-{\the\day} 13:00]

Связанный контент