% \iffalse % ====================================================================== % scrtime.dtx % Copyright © 1995–2026 Markus Kohm % % This work may be distributed and/or modified under the conditions of % the LaTeX Project Public License, version 1.3c of the license. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2005/12/01 or later and of this work. % % This work has the LPPL maintenance status "maintained". % % The current maintainer and author of this work is Markus Kohm. % % This work consists of the files README.md, LICENSE.md % and `scrtime.dtx`. % ====================================================================== %\NeedsTeXFormat{LaTeX2e}[2022/06/01] %<*dtx> \ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi \ProvidesFile{scrtime.dtx} % %\ProvidesPackage{scrtime} %<*dtx|package> [2026-05-19 v3.50 time of the LaTeX run] % %<*dtx> \ifx\documentclass\undefined \input docstrip.tex \askforoverwritefalse \generate{\usepreamble\defaultpreamble \file{scrtime.sty}{% \from{scrtime.dtx}{package}% }% } \else \let\endbatchfile\relax \fi \endbatchfile \documentclass[USenglish]{koma-script-source-doc} \usepackage{babel} \usepackage{scrtime} \setcounter{StandardModuleDepth}{2} \begin{document} \DocInput{scrtime.dtx} \end{document} % % \fi % % \changes{v3.36}{2022/02/07}{switch over from \cls*{scrdoc} to % \cls*{koma-script-source-doc}} % \changes{v3.36}{2022/02/07}{require package \pkg*{scrlogo} instead of % defining \cs{KOMAScript}} % \changes{v3.40}{2023/04/17}{guide names changed} % \changes{v3.50}{2026-05-18}{split-off to make a standalone package} % % \GetFileInfo{scrtime.dtx} % \title{The Current Time with % Package \pkg*{scrtime} \pkg*{scrdate}\footnote{The last \LaTeX{} run of % this document was at \today{} \thistime{}.}} % \author{\href{mailto:komascript@gmx.info}{Markus Kohm}} % \date{Version \fileversion{} of \filedate} % \maketitle % \begin{abstract} % This work provides a package \pkg*{scrtime} defining some macros to % handle compilation-time. It's a very simple implementation similar to % \pkg{time}. I've tried to not use additional registers. % % Up to version 3.49.2 it was part of the \KOMAScript{} collection. Since % version 3.50 it is a standalone package mostly distributed for % compatibility purpose. % \end{abstract} % \tableofcontents % % \section{User Manual} % % This package lets you find the current time. % % \begin{description} % \item[Important Note:] Since version~3.50, the package does no longer % support the \KOMAScript{} option interface using \cs{KOMAoption} and % \cs{KOMAoptions}. See the alternatives below. % \end{description} % % \DescribeCommand{\thistime} % This command prints the current time in hours and % minutes. Seconds are not supported, because \TeX{} itself does not provide % the seconds of the \LaTeX{} run. As a default delimiter a ``:'' is printed % between hours and minutes. Minutes values less than 10 are prefixed with a % leading 0. You can use an optional argument: % \begin{quotation} % \cs{thistime}\oarg{delimiter} % \end{quotation} % to change the default delimiter. For example, % \begin{verbatim}\thistime[.]\end{verbatim} % would show the time of the current \LaTeX{} run as, e.g., 9.01 instead of % the default 9:01. % % To prevent a leading 0 from being added to minutes values less than 10, the % asterisk form is available. So % \begin{verbatim}\thistime*\end{verbatim} % would show the time of the previous example as 9:1. The asterisk form still % provides the optional argument and % \begin{verbatim}\thistime*[.]\end{verbatim} % would show the time from above as 9.1. % % \DescribeCommand{\settime} % \cs{settime}\marg{time} sets the output of \cs{thistime} and % \cs{thistime*} to a fixed value. In this case, the optional parameter of % \cs{thistime} or \cs{thistime*} and the asterisk of \cs{thistime*} is % ignored, since the complete string returned by these commands has been % explicitly defined.\footnote{Internally, command \cs{thisime} is redefined % to ignore the asterisk and the optional argument and just return the % argument of \cs{settime}.} % % \DescribeOption{12h} % \DescribeOption{24h} % \DescribeCommand{\scrtimesetup} % With the options \opt{12h} and \opt{24h}, you can select whether to % print the time given by \cs{thistime} and \cs{thistime*} in 12- or 24-hour % format. The options accepts the values |true| and |false|. Option |24h| is % the same as |12h=false|. Option |24h=false| is the same as |12h|. The % default is \opt{24h}. % % You can set these options globally in the optional argument of % \cs{documentclass}, as a package option in the optional % argument of \cs{usepackage}, or even after loading the % package using \cs{scrtimesetup}. As a special, you can even use % \cs{usepackage} with different options several times in your document % preamble. The last wins. % % However the option no longer has any effect if you use \cs{settime}. After % invoking this command, the time is output only with the value and in the % format specified there. % % \MaybeStop{\PrintIndex} % % \section{Implementation} % % \subsection{Options} % % \begin{macrocode} %<*package> % \end{macrocode} % % \begin{option}{12h} % \changes{v1.1b}{1995/02/15}{option \opt{12h} added} % \changes{v1.2}{2010/03/10}{option uses \pkg*{scrkbase}} % \changes{v3.50}{2026-05-18}{\cs{KOMAoption} and \cs{KOMAoptions} not % supported any longer} % \changes{v3.50}{2026-05-18}{option uses \cs{DeclareKeys}} % \begin{option}{24h} % \changes{v1.1b}{1995/02/15}{option \opt{24h} added} % \changes{v1.2}{2010/03/10}{option is deprecated} % \changes{v3.39}{2022/11/16}{declare deprecated option only with % \KOMAScript~3} % \changes{v3.50}{2026-05-18}{option uses \cs{DeclareKeys}} % \begin{macro}{\if@Hxii,\@Hxiitrue,\@Hxiifalse} % \changes{v1.1b}{1995/02/15}{new switch} % There are the two options |24h| and |12h|. We need a switch to % distinguish. % \begin{macrocode} \newif\if@Hxii % \end{macrocode} % \end{macro} % So the options are simple. % \begin{macrocode} \DeclareKeys{% 12h.if = @Hxii, 12h.usage = general, 24h.ifnot = @Hxii, 24h.usage = general, } \ProcessKeyOptions % \end{macrocode} % \begin{command}{\scrtimesetup} % \changes{v3.50}{2026-05-18}{new} % Just a shortcut so users do not need to know the \meta{family}. % \begin{macrocode} \newcommand*{\scrtimesetup}{\SetKeys[scrtime]} % \end{macrocode} % \end{command} % \end{option} % \end{option} % % % \subsection{Commands and Macros} % % \begin{command}{\thistime} % \changes{v1.1b}{1995/02/15}{\cs{thistime*} added} % \changes{v1.1b}{1995/02/15}{\cs{thistime} fixed} % \changes{v3.20}{2016/04/12}{\cs{@ifstar} replaced by \cs{kernel@ifstar}} % \changes{v3.50}{2026-05-18}{using \cs{NewDocumentCommand}} % First we have to decide, is it a star-version ore not. % \begin{macrocode} \NewDocumentCommand{\thistime}{sO{:}}{% \begingroup \@tempcnta\time\divide\@tempcnta60\multiply\@tempcnta60 \@tempcntb\time\advance\@tempcntb-\@tempcnta \divide\@tempcnta60 % \end{macrocode} % If we use 12h-mode, we have to cut the houres. % \changes{v1.1d}{1996/01/14}{space added at \cs{@thistime} between -12 % and \cs{fi} (Martin Schroeder)} % \begin{macrocode} \if@Hxii\ifnum\@tempcnta>12 \advance\@tempcnta-12 \fi\fi % \end{macrocode} % Now we have to compose the value. If the minutes are less than 10 % maybe there has to be an additional 0. % \begin{macrocode} \the\@tempcnta #2\IfBooleanF{#1}{\ifnum\@tempcntb<10 0\fi}\the\@tempcntb \endgroup} % \end{macrocode} % \end{command} % % \begin{command}{\settime} % \changes{v1.1b}{1995/02/15}{redefines \cs{@thistime}} % \changes{v1.1c}{1995/05/24}{missing macrocode-environment inserted} % \changes{v3.50}{2026-05-18}{redefines \cs{thistime}} % We simply have to set \cs{@thistime}. % \begin{macrocode} \newcommand*{\settime}[1]{\RenewDocumentCommand{\thistime}{so}{#1}} % \end{macrocode} % \end{command} % % \begin{macrocode} % % \end{macrocode} % % \Finale % \PrintChanges % % \endinput % Local Variables: % mode: doctex % ispell-local-dictionary: "en_US" % eval: (flyspell-mode 1) % TeX-master: t % TeX-engine: luatex-dev % eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx")) % End: