
(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]