It is not uncommon (at least for me ) to compile pdf a day before. It is also not uncommon to use same pdf on some other day. So it would be handy if pdf produced displays the system date on which it is being played rather than compilation date. Is it possible?
Asked
Active
Viewed 5,217 times
4
3 Answers
5
If you know the date you'll be showing the PDF, just include that date in the preamble:
\date{06/06/66}
han-tyumi
- 1,152
- 8
- 17
3
It is not a real solution, but if you compile your document the day before, you can use following code to get a \Tomorrow command (please put it and the relevant packages into a separate .sty file if needed)
\documentclass{article}
\usepackage{datetime}
\usepackage{etoolbox}
\usepackage{calculator}
\makeatletter
\newif\ifIsLeapYear\IsLeapYearfalse
\newcommand*{\YearIsLeapYear}[1]{%
\IsLeapYearfalse%
\MODULO{#1}{4}{\ModuloFourResult}%
\ifnumcomp{\ModuloFourResult}{=}{0}{%
\MODULO{#1}{100}{\ModuloOneHundredResult}%
\ifnumcomp{\ModuloOneHundredResult}{=}{0}{%
\MODULO{#1}{400}{\ModuloFourHundredResult}%
\ifnumcomp{\ModuloFourHundredResult}{=}{0}{%
\IsLeapYeartrue%
}{%
\IsLeapYearfalse%
}%
}{%
\IsLeapYeartrue%
}}{\IsLeapYearfalse}%
}%
\newcounter{WorkSheet@@Day}%
\newcounter{WorkSheet@@Month}%
\newcounter{WorkSheet@@Year}%
\newcommand*{\WorkSheet@@SwitchToNextMonth}{%
\setcounter{WorkSheet@@Day}{1}%
\refstepcounter{WorkSheet@@Month}%
}%
\newcommand*{\WorkSheet@@SwitchToNextYear}{%
\setcounter{WorkSheet@@Day}{1}%
\setcounter{WorkSheet@@Month}{1}%
\refstepcounter{WorkSheet@@Year}%
}%
\newcommand*{\WorkSheetDayAfterDate}[3]{%
\setcounter{WorkSheet@@Day}{#1}%
\setcounter{WorkSheet@@Month}{#2}%
\setcounter{WorkSheet@@Year}{#3}%
%
\def\MonthsWithThirtyOneDays{1}%
\def\MonthsWithThirtyDays{4}%
%
%
\listadd{\MonthsWithThirtyOneDays}{1}%
\listadd{\MonthsWithThirtyOneDays}{3}%
\listadd{\MonthsWithThirtyOneDays}{5}%
\listadd{\MonthsWithThirtyOneDays}{7}%
\listadd{\MonthsWithThirtyOneDays}{8}%
\listadd{\MonthsWithThirtyOneDays}{10}%
\listadd{\MonthsWithThirtyOneDays}{12}%
%
\listadd{\MonthsWithThirtyDays}{4}%
\listadd{\MonthsWithThirtyDays}{6}%
\listadd{\MonthsWithThirtyDays}{9}%
\listadd{\MonthsWithThirtyDays}{11}%
\YearIsLeapYear{\number\value{WorkSheet@@Year}}%
\xifinlist{\number\value{WorkSheet@@Month}}{\MonthsWithThirtyOneDays}{% It is a "long month"
%
\ifnumcomp{\value{WorkSheet@@Day}}{=}{31}{% Is the 31st day in the month!
% Check for 12/31/...
\ifnumcomp{\value{WorkSheet@@Month}}{=}{12}{%
\WorkSheet@@SwitchToNextYear}{ \WorkSheet@@SwitchToNextMonth}%
}{\refstepcounter{WorkSheet@@Day}}}{%
\ifnumcomp{\value{WorkSheet@@Month}}{=}{2}{% It is February
\ifnumcomp{\value{WorkSheet@@Day}}{=}{28}{% Is the 28th of February
\ifIsLeapYear%
\refstepcounter{WorkSheet@@Day}%
\else%
\WorkSheet@@SwitchToNextMonth%
\fi%
}{%
\ifIsLeapYear%
\ifnumcomp{\value{WorkSheet@@Day}}{=}{29}{% Is the 29th of February
\WorkSheet@@SwitchToNextMonth}{\refstepcounter{WorkSheet@@Day}}%
\else%
\refstepcounter{WorkSheet@@Day}%
\fi%
}}{%
% It is a month with 30 days!!
\xifinlist{\number\value{WorkSheet@@Month}}{\MonthsWithThirtyDays}{%
\ifnumcomp{\value{WorkSheet@@Day}}{=}{30}{% Is the 30st day in the month!
\WorkSheet@@SwitchToNextMonth}{\refstepcounter{WorkSheet@@Day}
}}}{}%
}%
}%
\providecommand{\Tomorrow}{%
\WorkSheetDayAfterDate{\number\day}{\number\month}{\number\year}%
\newdate{DateOfTomorrow}{\number\value{WorkSheet@@Day}}{\number\value{WorkSheet@@Month}}{\number\value{WorkSheet@@Year}}%
\displaydate{DateOfTomorrow}
}%
\makeatother
\begin{document}
Tomorrow is \Tomorrow%
\end{document}
You can use the features of the datetime package in order to format the date according to your needs.
You still have to compile your document the day before, of course ;-)
2
This is just for the future visitors. tdclock package allows just what I expected. It only works with acrobat reader.
\documentclass{beamer}
\usetheme{madrid}
\usepackage[font=Times,timeinterval=10]{tdclock}
\title{Adding Current date}
\date{\tdclock}
\begin{document}
\initclock
\begin{frame}
\maketitle
\end{frame}
\begin{frame}{Ticking clock}\end{frame}
\end{document}
Vaibhav
- 6,625
- 15
- 49
- 76
pdffile itself, or you would have to useJavaScriptto fill form fields. I do not know how to change it otherwise. – Feb 16 '14 at 12:50\tomorrowcommand, which was a real hack. – Feb 16 '14 at 12:53tdclockpackage was suggested as a solution. Behind the scenes, it uses JS like @Christian says. – Crissov Feb 16 '14 at 15:22