Skip to content

Instantly share code, notes, and snippets.

Created June 30, 2013 15:28
Show Gist options
  • Save anonymous/5895586 to your computer and use it in GitHub Desktop.
Save anonymous/5895586 to your computer and use it in GitHub Desktop.
早いもので今年も既に何%が過ぎたかを示す文書
\documentclass[a4paper]{jsarticle}
\newcount\xxCntA
\newcount\xxCntB
\newcount\xxCntC
%% 例のMJDなアレ
\def\calcJulian#1#2#3#4{%
\xxCntA=#2\relax \xxCntB=#3\relax
\ifnum\xxCntA<1 \xxCntA=1 \fi
\ifnum\xxCntB<1 \xxCntB=1 \fi
\ifnum\xxCntB<3 \advance\xxCntB12 \advance\xxCntA-1 \fi
\mathchardef\xxTYear\xxCntA \chardef\xxTMonth\xxCntB
\multiply\xxCntA1461 \divide\xxCntA4
\xxCntB\xxTYear \divide\xxCntB100 \advance\xxCntA-\xxCntB
\divide\xxCntB4 \advance\xxCntA\xxCntB
\xxCntB\xxTMonth \advance\xxCntB-2
\multiply\xxCntB520 \divide\xxCntB17 \advance\xxCntA\xxCntB
\advance\xxCntA#4\relax \advance\xxCntA-678912
\edef#1{\the\xxCntA}%
}
\def\calcElapsed#1{%
\calcJulian\xxSoty{\year}{1}{1}%
\calcJulian\xxCday{\year}{\month}{\day}%
\xxCntC\year \advance\xxCntC1
\calcJulian\xxEoty{\xxCntC}{1}{1}%
\xxCntA\xxEoty \advance\xxCntA-\xxSoty
\multiply\xxCntA1440
\xxCntB\xxCday \advance\xxCntB-\xxSoty
\multiply\xxCntB1440 \advance\xxCntB\time
\multiply\xxCntB100 \divide\xxCntB\xxCntA
\edef#1{\the\xxCntB}%
}
\begin{document}
\calcElapsed\yer
早いもので今年も既にその\yer\%が過ぎてしまいました。
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment