diff options
author | Karl Berry <karl@freefriends.org> | 2009-11-19 01:22:32 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-11-19 01:22:32 +0000 |
commit | 985c15fd8ede8df9fa1f88aea533234471dc8be5 (patch) | |
tree | 5da4fd6cea3dbebba71f6ebd3d323d7328e45eb2 /Master/texmf-dist/source/latex/datetime | |
parent | 01d93d3639c9411877c1fcb7034fa3d4d36e3afe (diff) |
datetime update (18nov09)
git-svn-id: svn://tug.org/texlive/trunk@16071 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/datetime')
-rw-r--r-- | Master/texmf-dist/source/latex/datetime/datetime.dtx | 1052 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/datetime/datetime.ins | 8 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/datetime/datetime.perl | 2002 |
3 files changed, 2735 insertions, 327 deletions
diff --git a/Master/texmf-dist/source/latex/datetime/datetime.dtx b/Master/texmf-dist/source/latex/datetime/datetime.dtx index 0e1d7254c5c..d420ecc299a 100644 --- a/Master/texmf-dist/source/latex/datetime/datetime.dtx +++ b/Master/texmf-dist/source/latex/datetime/datetime.dtx @@ -3,11 +3,11 @@ % Command line args: % -src "(.+)\.(sty)=>\1.\2" % -src "(.+)\.(def)=>\1.\2" -% -doc "manual.tex" +% -doc "datetime-manual.tex" % -author "Nicola Talbot" % -dir "source" % datetime -% Created on 2007/8/20 15:37 +% Created on 2009/11/17 22:04 %\fi %\iffalse %<*package> @@ -30,7 +30,7 @@ %\fi % \iffalse % Doc-Source file to use with LaTeX2e -% Copyright (C) 2007 Nicola Talbot, all rights reserved. +% Copyright (C) 2009 Nicola Talbot, all rights reserved. % \fi % \iffalse %<*driver> @@ -43,7 +43,7 @@ pdftitle={datetime.sty: A Date and Time Package}, pdfkeywords={date,time,LaTeX}]{hyperref} -\CheckSum{4044} + \newcommand{\sty}[1]{\textsf{#1}} \begin{document} @@ -54,7 +54,7 @@ %\RecordChanges %\OnlyDescription % -%\title{datetime.sty v2.55: Formatting Current Date and +%\title{datetime.sty v2.56: Formatting Current Date and %Time} % \author{Nicola L. C. Talbot\\[10pt] % School of Computing Sciences\\ @@ -62,7 +62,7 @@ % Norwich. NR4 7TJ.\\ % United Kingdom.\\ % \url{http://theoval.cmp.uea.ac.uk/~nlct/}} -% \date{20 Aug 2007} +% \date{16th November 2009} % \maketitle % \tableofcontents % \section{Introduction} @@ -100,11 +100,20 @@ %\usepackage{datetime} %\end{verbatim} % -% \section{Date Declarations} +% \section{Predefined Date Formats} % There are various declarations that change the effect of %\cs{today}. The change can be localised by placing the %declaration within a group. % +% +% \vspace{10pt}\noindent ISO format: +% \DescribeMacro{\yyyymmdddate} +% The declaration \verb"\yyyymmdddate" will redefine +%\verb"\today" to produce +% the current date displayed in the form 2000/03/08. (You can +%redefine \cs{dateseparator} to \texttt{-} to change to +%2000-03-08.) +% % \vspace{10pt}\noindent \meta{Day} \meta{Month} \meta{Year} formats:\\ % \noindent\DescribeMacro{\longdate} % The declaration \verb"\longdate" will redefine @@ -189,17 +198,19 @@ %\DescribeMacro{\currenttime} % The current time is displayed using the command %\verb"\currenttime". +% +%\DescribeMacro{\formattime}A specific time can be displayed using +%the command \cs{formattime}\marg{hour}\marg{minute}\marg{second}, where +%\meta{hour} is a number from~0 to~23, and \meta{minute} and +%\meta{second} are numbers from~0 to~59. +% %\DescribeMacro{\settimeformat} % The format can be changed using the declaration %\cs{settimeformat}\marg{style}, where \meta{style} is the name of the -%format\footnote{Note that the commands \cs{xxivtime}, \cs{ampmtime} -%and \cs{oclock} are still available, \cs{settimeformat} redefines -%\cs{currenttime} to the command given by placing a backslash in front -%of \meta{style}. So \cs{settimeformat\{xxivtime\}} sets -%\cs{currenttime} to \cs{xxivtime} and so on.}. Available formats -%are: +%format. Predefined formats are: %\begin{description} %\item[xxivtime] Twenty-four hour time in the form 22:28 (Default) +%\item[hhmmsstime] Twenty-four hour time in the form 22:28:00 %\item[ampmtime] Twelve hour time in the form 10:28pm %\item[oclock] Displays the current time as a string, e.g.\ %Twenty-Eight minutes past Ten in the afternoon. @@ -212,10 +223,11 @@ %\cs{settimeformat}), and \meta{format} is how to format the %time. Within \meta{format} you can use the counters %\texttt{HOUR} (number of hours after midnight), \texttt{MINUTE} -%(number of minutes past the hour), \texttt{HOURXII} (number of +%(number of minutes past the hour), \texttt{SECOND} (number of +%seconds) \texttt{HOURXII} (number of %hours after midnight/midday), \texttt{TOHOUR} (the next hour) and %\texttt{TOMINUTE} (number of minutes to the next hour), and the -%corresponding commands: \cs{THEHOUR}, \cs{THEMINUTE}, +%corresponding commands: \cs{THEHOUR}, \cs{THEMINUTE}, \cs{THESECOND}, %\cs{THEHOURXII}, \cs{THETOHOUR} and \cs{THETOMINUTE}. % %For example, to define a new time format that uses a dot instead of a @@ -257,6 +269,10 @@ % /ModDate (D:\pdfdate) %} %\end{verbatim} +%\textbf{Note} that PDF\TeX\ introduced the new primitive +%\cs{pdfcreationdate} in version 1.30.0, so \cs{pdfdate} isn't +%required with newer versions of PDF\TeX. (\cs{pdfcreationdate} +%is better than \cs{pdfdate} as it also stores the time zone.) % % There are two commands that print the name of the current % month: @@ -454,6 +470,7 @@ % \begin{tabular}{@{\ttfamily}ll} % long & make \cs{today} produce long date\\ % short & make \cs{today} produce short date\\ +% yyyymmdd & make \cs{today} produce YYYY/MM/DD date\\ % ddmmyyyy & make \cs{today} produce DD/MM/YYYY date\\ % dmyyyy & make \cs{today} produce D/M/YYYY date\\ % ddmmyy & make \cs{today} produce DD/MM/YY date\\ @@ -471,6 +488,8 @@ %\cs{shortdate} \\ % & or \cs{textdate}\\ % nodayofweek & don't display the day of week.\\ +% hhmmss & make \cs{currenttime} produce \texttt{hhmmsstime} +%format\\ % 24hr & make \cs{currenttime} produce \texttt{xxivtime} %format\\ % 12hr & make \cs{currenttime} produce \texttt{ampmtime} @@ -479,8 +498,9 @@ %format\\ % nodate & Don't redefine \cs{today} or define the month or %day of week commands\\ -% & (useful if you only want the time commands or -%\verb"\pdfdate") +% & (useful if you only want the time commands) \\ +% iso & as ddmmyyyy and hhmmss but also sets date separator to -\\ +%& and time separator to : % \end{tabular} % %The default options are: \texttt{long}, \texttt{raise}, @@ -488,6 +508,12 @@ % %\section{Multilingual Support} % +%If you use the \sty{ngerman} package, you must use \sty{datetime}'s +%\texttt{ngerman} package option if you want the date displayed +%in the same form as \sty{ngerman}. You must also load \sty{ngerman} +%\emph{before} you load \sty{datetime}. Similarly for the +%\sty{german} package. +% %If you want to use the \sty{babel} package, you must load %it \emph{before} you load the \sty{datetime} package. This %is because the \sty{babel} \cs{date}\meta{lang} commands @@ -504,6 +530,28 @@ %languages that I know, or that other people have been able to supply %for me. % +%As from v2.56, the package options supplied to \sty{datetime} +%override \sty{babel}'s date format. For example: +%\begin{verbatim} +%\usepackage[french,spanish]{babel} +%\usepackage[ddmmyyyy]{datetime} +%\end{verbatim} +%will use ddmmyyyy date format regardless of language. Note that +%if you use a declaration instead of a package option, for +%example: +%\begin{verbatim} +%\usepackage[french,spanish]{babel} +%\usepackage{datetime} +%\ddmmyyyydate +%\end{verbatim} +%the date format will be switched back to \cs{datefrench} or +%\cs{datespanish} whenever the language is set. You can use\par +%\noindent\DescribeMacro{\setdefaultdate}\cs{setdefaultdate}\marg{declaration}\par +%\noindent to always use \marg{declaration} whenever the language +%is set. For example: +%\begin{verbatim} +%\setdefaultdate{\ddmmyyyydate} +%\end{verbatim} % %The commands \cs{monthname} and \cs{shortmonthname}, %will produce the month name in the current language. @@ -526,7 +574,7 @@ %\cs{dayofweeknameid}\meta{lang} and %\cs{shortdayofweeknameid}\meta{lang}. Note that these %commands only take \emph{one} argument which should be -%a number from 1 to 7 indicating the day of the week. +%a number from~1 to~7 indicating the day of the week. % %You can use the following as templates. Replace %\texttt{english} with the name of your language (as given @@ -558,6 +606,14 @@ %If you want them added to future versions of %\sty{datetime}, please email me the code. % +%\section{Registers} +% +%\TeX\ provides \cs{day}, \cs{month}, \cs{year} registers. In +%addition, \sty{datetime} provides the registers: +%\cs{currenthour}, \cs{currentminute} and \cs{currentsecond}. +%Note that old distributions of \TeX\ will always have +%\cs{currentsecond} set to zero. +% %\section{Configuration File} % %As from Version 2.4, the \sty{datetime} package will read in settings @@ -636,13 +692,18 @@ % This section documents the code for \texttt{datetime.sty} % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{datetime}[2007/08/20 v2.55 Date Time Package] +\ProvidesPackage{datetime}[2009/11/16 v2.56 Date Time Package] % \end{macrocode} %\texttt{fmtcount.sty} needs to be loaded here as it defines the % command \cs{fmtord} which may be redefined later: % \begin{macrocode} \RequirePackage{fmtcount} % \end{macrocode} +% Need ifthen package for conditional stuff. +% \begin{macrocode} +\RequirePackage{ifthen} +% \end{macrocode} +%\subsubsection{Date Commands} %\begin{macro}{\if@dtl@nodate} % Define a new conditional \cs{if@dt@nodate}. If it is true, % \cs{today} will not be redefined, nor will @@ -682,35 +743,13 @@ % Define the \cs{ordinaldate}\meta{language} macros. These are % needed because some % languages only use an ordinal for the first day of -% the month (such as french). This isn't really needed -% here, but the LaTeX2HTML style file needs \cs{ordinaldate}. +% the month (such as french). %\begin{macro}{\ordinaldateenglish} % English version: % \begin{macrocode} \newcommand*{\ordinaldateenglish}[1]{\ordinalnum{#1}} % \end{macrocode} %\end{macro} -%\begin{macro}{\ordinaldatewelsh} -% Welsh version: -% \begin{macrocode} -\newcommand*{\ordinaldatewelsh}[1]{% -#1\ifnum#1=1\/\textsuperscript{a\~n}\fi} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\ordinaldatebreton} -% Breton version: -% \begin{macrocode} -\newcommand*{\ordinaldatebreton}[1]{% -#1\ifnum#1=1\/\textsuperscript{a\~n}\fi} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\ordinaldatefrench} -% French: -% \begin{macrocode} -\newcommand*{\ordinaldatefrench}[1]{% -#1\ifnum#1=1\ier\fi} -% \end{macrocode} -%\end{macro} %\begin{macro}{\ordinaldate} % If |\ordinaldate|\meta{language} is not defined, then just display % the number. @@ -725,14 +764,6 @@ \fi} % \end{macrocode} %\end{macro} -%\begin{macro}{\ier} -% In case \verb|\ier| hasn't been defined:% -%\changes{v2.47}{27 Oct 2005}{defined if it doesn't -% already exist} -% \begin{macrocode} -\providecommand*{\ier}{\textsuperscript{er}} -% \end{macrocode} -%\end{macro} %\begin{macro}{\ifshowdow} % Now define the declarations that redefine |\formatdate| as they % are used by the package options. Need a conditional to determine @@ -786,6 +817,18 @@ \let\twodigit\two@digits % \end{macrocode} %\end{macro} +%\begin{macro}{\yyyymmdddate} +%\changes{2.56}{2009/11/16}{new} +% Year/month/day format. (Day and month displayed as two digits, +% year displayed as is.) +% \begin{macrocode} +\DeclareRobustCommand*{\yyyymmdddate}{% +\renewcommand*{\formatdate}[3]{% +\@day=##1\relax\@month=##2\relax\@year=##3\relax +\the\@year\dateseparator \twodigit\@month\dateseparator +\twodigit\@day}} +% \end{macrocode} +%\end{macro} %\begin{macro}{\ddmmyyyydate} % Day/month/year format. (Day and month displayed as two digits, % year displayed as is.) @@ -942,11 +985,70 @@ \csname date@#1@y\endcsname}}} % \end{macrocode} %\end{macro} +% Set defaults: +% \begin{macrocode} +\longdate +\showdowtrue +% \end{macrocode} +% +%\changes{2.56}{2009/11/16}{moved definition of \cs{newdateformat} +% before cfg file loaded} +% Define |\newdateformat| which defines a declaration that redefines |\formatdate| so that +% it uses |\dateformat|. |\dateformat| takes four arguments, the first defines the format +% the last three arguments are the three arguments that effectively get passed to |\formatdate|. +% |\dateformat| sets |\@day|, |\@month| and |\@year|. |\c@DAY|, |\c@MONTH| and |\c@YEAR| +% are set as synonims for |\@day|, |\@month| and |\@year|, to that the uses can use the counters +% |DAY|, |MONTH| and |YEAR| as part of the format. +% The commands |\THEDAY|, |\THEMONTH| and |\THEYEAR| should only be +% used in the argument to |\newdateformat|. This is done partly to +% assist the \LaTeX2HTML version. +% +% This command must be defined before the configuration file is +% loaded, which in turn must be before the package options, therefore +% can't test for \texttt{nodate} package option. +% \begin{macrocode} +\providecommand*\THEDAY{\the\@day} +\providecommand*\THEMONTH{\the\@month} +\providecommand*\THEYEAR{\the\@year} +% \end{macrocode} +% Simulate a \LaTeX\ counter. +% \begin{macrocode} +\let\c@DAY=\@day +\let\c@MONTH=\@month +\let\c@YEAR=\@year +% \end{macrocode} +%\begin{macro}{\newdateformat} +% Provide a means to define a new date format. +%\changes{2.2}{2004/04/27}{new} +% \begin{macrocode} +\providecommand{\newdateformat}[2]{% +\@ifundefined{#1}{% +\expandafter\DeclareRobustCommand\csname#1\endcsname{% +\renewcommand{\formatdate}{\dateformat{#2}}}}{% +\PackageError{datetime}{Can't create new date format, command +\textbackslash#1 already defined}{You will need to +give your new date format a different name}}} +% \end{macrocode} +%\end{macro} +% \subsubsection{Time Macros} %\begin{macro}{\currenttime} % (New to v2.3) Define |\currenttime| which will print the -% time according to the current format. Set it to 24hr time by default +% time according to the current format. +%\changes{2.56}{2009/11/16}{change to use \cs{formattime}} % \begin{macrocode} -\DeclareRobustCommand*{\currenttime}{\xxivtime} +\DeclareRobustCommand*{\currenttime}{% + \formattime{\currenthour}{\currentminute}{\currentsecond}% +} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\formattime} +% Define \cs{formattime} analoguous to \cs{formatdate}. +% Set it to 24hr time by default +%\changes{2.56}{2009/11/16}{new} +% \begin{macrocode} +\newcommand*{\formattime}[3]{\protect\@formattime{#1}{#2}{#3}} +\newcommand*{\@formattime}[3]{% + \csname timeformat@xxivtime\endcsname{#1}{#2}{#3}} % \end{macrocode} %\end{macro} %\begin{macro}{\timeseparator} @@ -959,16 +1061,252 @@ %\begin{macro}{\settimeformat} % Switch to specified time format: %\changes{2.3}{2004/05/01}{new} +%\changes{2.56}{2009/11/16}{now sets formattime} % \begin{macrocode} \providecommand*{\settimeformat}[1]{% -\DeclareRobustCommand*\currenttime{\csname#1\endcsname}} + \@ifundefined{timeformat@#1}{% + \PackageError{datetime}{Unknown time format `#1'}{}% + }{% + \renewcommand*{\@formattime}[3]{% + \csname timeformat@#1\endcsname{##1}{##2}{##3}}% + }% +} % \end{macrocode} %\end{macro} -% Set defaults: +% Define a command to create a new time format, similar to the new +% date format. Again this is done in a way that makes it easier to +% code the \LaTeX2HTML version. % \begin{macrocode} -\longdate -\showdowtrue +\newcount\c@HOUR +\newcount\c@HOURXII +\newcount\c@MINUTE +\newcount\c@TOHOUR +\newcount\c@TOMINUTE +\newcount\c@SECOND +% \end{macrocode} +% These commands should only be used in |\newtimeformat|. +% \begin{macrocode} +\def\THEHOUR{\the\c@HOUR} +\def\THEHOURXII{\the\c@HOURXII} +\def\THEMINUTE{\the\c@MINUTE} +\def\THETOHOUR{\the\c@TOHOUR} +\def\THETOMINUTE{\the\c@TOMINUTE} +\def\THESECOND{\the\c@SECOND} +% \end{macrocode} +%\begin{macro}{\currenthour} +%\changes{2.56}{2009/11/16}{new} +% Store the current hour +% \begin{macrocode} +\newcount\currenthour +% \end{macrocode} +%\end{macro} +%\begin{macro}{\currentminute} +%\changes{2.56}{2009/11/16}{new} +% Store current minute +% \begin{macrocode} +\newcount\currentminute +% \end{macrocode} +%\end{macro} +%\begin{macro}{\currentsecond} +%\changes{2.56}{2009/11/16}{new} +\newcount\currentsecond +%\end{macro} +% Get time information from \cs{pdfcreationdate} (if it exists) +% \begin{macrocode} +{\catcode`\D=12\relax + \gdef\@dt@getdate D:#1#2#3#4#5#6#7#8{\@dt@gettime}% +} +\@ifundefined{pdfcreationdate}{% + \currenthour=\time\relax + \divide\currenthour by 60\relax + \currentminute=\time\relax + \@modulo{\currentminute}{60}% + \currentsecond=0\relax +}{% + \def\@dt@gettime#1#2#3#4#5#6#7\relax{% + \currenthour=#1#2\relax + \currentminute=#3#4\relax + \currentsecond=#5#6\relax}% + \expandafter\@dt@getdate\pdfcreationdate\relax +} +% \end{macrocode} +%\begin{macro}{\newtimeformat} +% Provide a means to define a new time format. +%\changes{2.3}{2004/05/01}{new} +%\changes{2.56}{2009/11/16}{added \cs{timeformat}@\meta{name}} +% \begin{macrocode} +\providecommand*{\newtimeformat}[2]{% +\@ifundefined{#1}{% +\expandafter\def\csname#1\endcsname{% + \csname timeformat@#1\endcsname{\currenthour}{\currentminute}% + {\currentsecond}% +}% +\expandafter\def\csname timeformat@#1\endcsname##1##2##3{% +\c@HOUR=##1% +\c@HOURXII=\c@HOUR +\ifnum\c@HOURXII>12 +\advance\c@HOURXII by -12\relax +\fi +\c@MINUTE=##2% +\c@TOHOUR=\c@HOURXII +\advance\c@TOHOUR by 1\relax +\@modulo{\c@TOHOUR}{12}% +\c@TOMINUTE=\c@MINUTE +\advance\c@TOMINUTE by -60\relax +\multiply\c@TOMINUTE by -1\relax +\c@SECOND=##3\relax +#2\relax +}}{% +\PackageError{datetime}{Command \textbackslash#1 already defined}{% +You can't create a new time format called "#1" as the command +\textbackslash#1 already exists}}} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\xxivtime} +% Define commands to print the current time. Twenty-four hour time: +% \begin{macrocode} +\newtimeformat{xxivtime}{% +\twodigit\THEHOUR\timeseparator\twodigit\THEMINUTE} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\hhmmsstime} +% Twenty-four hour time including seconds. +% \begin{macrocode} +\newtimeformat{hhmmsstime}{% +\twodigit\THEHOUR\timeseparator\twodigit\THEMINUTE\timeseparator +\twodigit\THESECOND} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\ampmtime} +% 12-hour time: +%\changes{2.3}{2004/05/01}{fixed minor bug} +%\changes{2.51}{2007/01/30}{fixed bug between midnight and 1am} +% \begin{macrocode} +\newtimeformat{ampmtime}{% +\ifthenelse{\value{HOUR}=0}{12}{\THEHOURXII}\timeseparator +\twodigit\THEMINUTE +\ifthenelse{\value{HOUR}<12}{\amname}{% +\ifthenelse{\value{HOUR}=12}{ \noon}{\pmname}}} +% \end{macrocode} +%\end{macro} +% Textual time: +%\begin{macro}{\hourstring} +% \cs{hourstring}\marg{count} will print |\midnight| if +% \meta{count} is 0, otherwise will do \cs{Numberstring}\marg{count}. +% \begin{macrocode} +\newcommand*{\hourstring}[1]{% +\ifthenelse{\value{#1}=0}{\midnight}{\Numberstring{#1}}} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\oclock} +%\changes{2.43}{2005/02/23}{fixed bug causing an infinite loop on the hour} +% \begin{macrocode} +\newtimeformat{oclock}{% + \ifthenelse{\(\value{HOUR}=0 \OR \value{HOUR}=12 \OR\value{HOUR}=24\)\AND + \value{MINUTE}=0}{% +% \end{macrocode} +% Midnight or Midday: +% \begin{macrocode} +\ifthenelse{\value{HOUR}=12}{\noon}{\midnight}}{% % \end{macrocode} +% Neither Midnight nor Midday. +% Do minutes first +% \begin{macrocode} +\ifthenelse{\value{MINUTE}=0}{% +% \end{macrocode} +% On the hour: don't print any minutes, just do the hour and +% |\oclockstring| +% \begin{macrocode} +\Numberstring{HOUR} \oclockstring}{% +\ifthenelse{\value{MINUTE}=15}{% +\quarterpast\ \hourstring{HOUR}}{% +\ifthenelse{\value{MINUTE}=30}{% +\halfpast\ \hourstring{HOUR}}{% +\ifthenelse{\value{MINUTE}=45}{% +\quarterto\ \hourstring{TOHOUR}}{% +\ifthenelse{\value{MINUTE}<30}{% +\Numberstring{MINUTE}\ \ifthenelse{\value{MINUTE}=1}{minute}{minutes} +past \hourstring{HOURXII}}{% +\Numberstring{TOMINUTE}\ \ifthenelse{% +\value{TOMINUTE}=1}{minute}{minutes} to \hourstring{TOHOUR}}}}}}% +% \end{macrocode} +% Now say whether it is morning or afternoon +% \begin{macrocode} +\ifthenelse{\value{HOUR}<12}{% +% \end{macrocode} +% Morning +% \begin{macrocode} +\ifthenelse{\value{HOUR}=0}{}{\ \amstring}}{% +% \end{macrocode} +% Afternoon +% \begin{macrocode} +\ifthenelse{\value{TOHOUR}=0}{}{\ \pmstring}}}} +% \end{macrocode} +%\end{macro} +% Define textual strings used in the above. +%\begin{macro}{\amname} +% \begin{macrocode} +\providecommand*{\amname}{am} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\pmname} +% \begin{macrocode} +\providecommand*{\pmname}{pm} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\amorpmname} +% \begin{macrocode} +\providecommand*{\amorpmname}{% +\ifthenelse{\value{HOUR}>12}{\pmname}{\amname}} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\amstring} +% \begin{macrocode} +\providecommand*{\amstring}{in the morning} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\pmstring} +% \begin{macrocode} +\providecommand*{\pmstring}{in the afternoon} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\amorpmstring} +% \begin{macrocode} +\providecommand*{\amorpmstring}{% +\ifthenelse{\value{HOUR}>12}{\pmstring}{\amstring}} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\halfpast} +% \begin{macrocode} +\providecommand*{\halfpast}{Half past} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\quarterpast} +% \begin{macrocode} +\providecommand*{\quarterpast}{Quarter past} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\quarterto} +% \begin{macrocode} +\providecommand*{\quarterto}{Quarter to} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\noon} +% \begin{macrocode} +\providecommand*{\noon}{Noon} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\midnight} +% \begin{macrocode} +\providecommand*{\midnight}{Midnight} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\oclockstring} +% \begin{macrocode} +\providecommand*{\oclockstring}{O'Clock} +% \end{macrocode} +%\end{macro} +%\subsubsection{Configuration File} % Load in specifications from configuration file: %\changes{2.4}{2004/09/25}{added provision for configuration file %datetime.cfg} @@ -978,37 +1316,198 @@ Loading local datetime configurations}}{% \PackageInfo{datetime}{No datetime.cfg file found, using default settings}} % \end{macrocode} +%\subsubsection{Package Options} +% Package options need to override \sty{babel}, so define command to +% add date format to \sty{babel}'s extras. +% \begin{macrocode} +\@ifpackageloaded{babel}{% + \newcommand*{\dt@addtoextras}[1]{% + \@ifundefined{extrasenglish}{}{% + \addto\extrasenglish{#1}% + }% + \@ifundefined{extrasamerican}{}{% + \addto\extrasamerican{#1}% + }% + \@ifundefined{extrasaustrian}{}{% + \addto\extrasaustrian{#1}% + }% + \@ifundefined{extrasbahasa}{}{% + \addto\extrasbahasa{#1}% + }% + \@ifundefined{extrasbreton}{}{% + \addto\extrasbreton{#1}% + }% + \@ifundefined{extrasbritish}{}{% + \addto\extrasbritish{#1}% + }% + \@ifundefined{extrasbulgarian}{}{% + \addto\extrasbulgarian{#1}% + }% + \@ifundefined{extrascatalan}{}{% + \addto\extrascatalan{#1}% + }% + \@ifundefined{extrascroatian}{}{% + \addto\extrascroatian{#1}% + }% + \@ifundefined{extrasczech}{}{% + \addto\extrasczech{#1}% + }% + \@ifundefined{extrasdanish}{}{% + \addto\extrasdanish{#1}% + }% + \@ifundefined{extrasesperanto}{}{% + \addto\extrasesperanto{#1}% + }% + \@ifundefined{extrasestonian}{}{% + \addto\extrasestonian{#1}% + }% + \@ifundefined{extrasfinnish}{}{% + \addto\extrasfinnish{#1}% + }% + \@ifundefined{extrasfrench}{}{% + \addto\extrasfrench{#1}% + }% + \@ifundefined{extrasgalician}{}{% + \addto\extrasgalician{#1}% + }% + \@ifundefined{extrasgerman}{}{% + \addto\extrasgerman{#1}% + }% + \@ifundefined{extrasgreek}{}{% + \addto\extrasgreek{#1}% + }% + \@ifundefined{extrashebrew}{}{% + \addto\extrashebrew{#1}% + }% + \@ifundefined{extrasicelandic}{}{% + \addto\extrasicelandic{#1}% + }% + \@ifundefined{extrasirish}{}{% + \addto\extrasirish{#1}% + }% + \@ifundefined{extrasitalian}{}{% + \addto\extrasitalian{#1}% + }% + \@ifundefined{extraslatin}{}{% + \addto\extraslatin{#1}% + }% + \@ifundefined{extraslsorbian}{}{% + \addto\extraslsorbian{#1}% + }% + \@ifundefined{extrasmagyar}{}{% + \addto\extrasmagyar{#1}% + }% + \@ifundefined{extrasnaustrian}{}{% + \addto\extrasnaustrian{#1}% + }% + \@ifundefined{extrasngerman}{}{% + \addto\extrasngerman{#1}% + }% + \@ifundefined{extrasnorsk}{}{% + \addto\extrasnorsk{#1}% + }% + \@ifundefined{extraspolish}{}{% + \addto\extraspolish{#1}% + }% + \@ifundefined{extrasportuges}{}{% + \addto\extrasportuges{#1}% + }% + \@ifundefined{extrasromanian}{}{% + \addto\extrasromanian{#1}% + }% + \@ifundefined{extrasrussian}{}{% + \addto\extrasrussian{#1}% + }% + \@ifundefined{extrassamin}{}{% + \addto\extrassamin{#1}% + }% + \@ifundefined{extrasscottish}{}{% + \addto\extrasscottish{#1}% + }% + \@ifundefined{extrasserbian}{}{% + \addto\extrasserbian{#1}% + }% + \@ifundefined{extrasslovak}{}{% + \addto\extrasslovak{#1}% + }% + \@ifundefined{extrasslovene}{}{% + \addto\extrasslovene{#1}% + }% + \@ifundefined{extrasspanish}{}{% + \addto\extrasspanish{#1}% + }% + \@ifundefined{extrasswedish}{}{% + \addto\extrasswedish{#1}% + }% + \@ifundefined{extrasturkish}{}{% + \addto\extrasturkish{#1}% + }% + \@ifundefined{extrasUKenglish}{}{% + \addto\extrasUKenglish{#1}% + }% + \@ifundefined{extrasukraine}{}{% + \addto\extrasukraine{#1}% + }% + \@ifundefined{extrasUSenglish}{}{% + \addto\extrasUSenglish{#1}% + }% + \@ifundefined{extrasusorbian}{}{% + \addto\extrasusorbian{#1}% + }% + \@ifundefined{extraswelsh}{}{% + \addto\extraswelsh{#1}% + }% + } +}{% + \newcommand*{\dt@addtoextras}[1]{} +} +% \end{macrocode} +%\begin{macro}{setdefaultdate} +% Set default date. +% \begin{macrocode} +\newcommand*{\setdefaultdate}[1]{\dt@addtoextras{#1}#1} +% \end{macrocode} +%\end{macro} % Specify the package options, specify default options and process % \begin{macrocode} \RequirePackage{fmtcount} -\DeclareOption{long}{\longdate} -\DeclareOption{short}{\shortdate} -\DeclareOption{ddmmyyyy}{\ddmmyyyydate} -\DeclareOption{dmyyyy}{\dmyyyydate} -\DeclareOption{ddmmyy}{\ddmmyydate} -\DeclareOption{dmyy}{\dmyydate} -\DeclareOption{text}{\textdate} -\DeclareOption{us}{\usdate} -\DeclareOption{mmddyyyy}{\mmddyyyydate} -\DeclareOption{mdyyyy}{\mdyyyydate} -\DeclareOption{mmddyy}{\mmddyydate} -\DeclareOption{mdyy}{\mdyydate} +\DeclareOption{long}{\setdefaultdate{\longdate}} +\DeclareOption{short}{\setdefaultdate{\shortdate}} +\DeclareOption{yyyymmdd}{\setdefaultdate{\yyyymmdddate}} +\DeclareOption{ddmmyyyy}{\setdefaultdate{\ddmmyyyydate}} +\DeclareOption{dmyyyy}{\setdefaultdate{\dmyyyydate}} +\DeclareOption{ddmmyy}{\setdefaultdate{\ddmmyydate}} +\DeclareOption{dmyy}{\setdefaultdate{\dmyydate}} +\DeclareOption{text}{\setdefaultdate{\textdate}} +\DeclareOption{us}{\setdefaultdate{\usdate}} +\DeclareOption{mmddyyyy}{\setdefaultdate{\mmddyyyydate}} +\DeclareOption{mdyyyy}{\setdefaultdate{\mdyyyydate}} +\DeclareOption{mmddyy}{\setdefaultdate{\mmddyydate}} +\DeclareOption{mdyy}{\setdefaultdate{\mdyydate}} \DeclareOption{level}{\fmtcountsetoptions{fmtord=level}} \DeclareOption{raise}{\fmtcountsetoptions{fmtord=raise}} \DeclareOption{dayofweek}{\showdowtrue} \DeclareOption{nodayofweek}{\showdowfalse} \DeclareOption{nodate}{\@dt@nodatetrue} +\DeclareOption{hhmmss}{\settimeformat{hhmmsstime}} \DeclareOption{24hr}{\settimeformat{xxivtime}} \DeclareOption{12hr}{\settimeformat{ampmtime}} \DeclareOption{oclock}{\settimeformat{oclock}} +\DeclareOption{iso}{% + \setdefaultdate{\yyyymmdddate}\settimeformat{hhmmsstime}% + \renewcommand*{\dateseparator}{-}% + \renewcommand*{\timeseparator}{:}% +} % \end{macrocode} % Multilingual support. These package options shouldn't really be % needed if babel has already been loaded. % \begin{macrocode} \DeclareOption{austrian}{\input{dt-austrian.def}} +\DeclareOption{american}{\input{dt-american.def}} \DeclareOption{bahasa}{\input{dt-bahasa.def}} \DeclareOption{basque}{\input{dt-basque.def}} \DeclareOption{breton}{\input{dt-breton.def}} +\DeclareOption{british}{\input{dt-british.def}} \DeclareOption{bulgarian}{\input{dt-bulgarian.def}} \DeclareOption{catalan}{\input{dt-catalan.def}} \DeclareOption{croatian}{\input{dt-croatian.def}} @@ -1020,7 +1519,7 @@ settings}} \DeclareOption{finnish}{\input{dt-finnish.def}} \DeclareOption{french}{\input{dt-french.def}} \DeclareOption{galician}{\input{dt-galician.def}} -\DeclareOption{german}{\input{dt-german.def}} +\DeclareOption{german}{\input{dt-german.def}\dategerman} \DeclareOption{greek}{\input{dt-greek.def}} \DeclareOption{hebrew}{\input{dt-hebrew.def}} \DeclareOption{icelandic}{\input{dt-icelandic.def}} @@ -1030,7 +1529,7 @@ settings}} \DeclareOption{lsorbian}{\input{dt-lsorbian.def}} \DeclareOption{magyar}{\input{dt-magyar.def}} \DeclareOption{naustrian}{\input{dt-naustrian.def}} -\DeclareOption{ngerman}{\input{dt-ngerman.def}} +\DeclareOption{ngerman}{\input{dt-ngerman.def}\datengerman} \DeclareOption{norsk}{\input{dt-norsk.def}} \DeclareOption{polish}{\input{dt-polish.def}} \DeclareOption{portuges}{\input{dt-portuges.def}} @@ -1046,17 +1545,31 @@ settings}} \DeclareOption{turkish}{\input{dt-turkish.def}} \DeclareOption{ukraineb}{\input{dt-ukraineb.def}} \DeclareOption{usorbian}{\input{dt-usorbian.def}} +\DeclareOption{UKenglish}{\input{dt-UKenglish.def}} +\DeclareOption{USenglish}{\input{dt-USenglish.def}} \DeclareOption{welsh}{\input{dt-welsh.def}} % \end{macrocode} % Process package options % \begin{macrocode} \ProcessOptions % \end{macrocode} -% Need ifthen package for conditional stuff. +% \subsubsection{Date Specific Macros} % \begin{macrocode} -\RequirePackage{ifthen} +\if@dt@nodate + \PackageInfo{datetime}{option "nodate" used, so note defining +\string\dateformat} +\else +% \end{macrocode} +%\begin{macro}{\dateformat} +% Format the given date in the given format. +% \begin{macrocode} +\providecommand*{\dateformat}[4]{% +\@day=#2\relax\@month=#3\relax\@year=#4\relax#1} +% \end{macrocode} +%\end{macro} +% \begin{macrocode} +\fi % \end{macrocode} -% \subsubsection{Date Macros} % Define the macro that prints the month name. % (Only define this command if @dt@nodate is false) % \begin{macrocode} @@ -1401,6 +1914,7 @@ language '\languagename', defaulting to long version}}% \@ifundefined{dateUKenglish}{}{\input{dt-UKenglish.def}} \@ifundefined{dateUSenglish}{}{\input{dt-USenglish.def}} \@ifundefined{datebritish}{}{\input{dt-british.def}} +\@ifundefined{dateamerican}{}{\input{dt-american.def}} \@ifundefined{dateaustrian}{}{\input{dt-austrian.def}} \@ifundefined{datebahasa}{}{\input{dt-bahasa.def}} \@ifundefined{datebasque}{}{\input{dt-basque.def}} @@ -1446,243 +1960,12 @@ language '\languagename', defaulting to long version}}% \fi % \end{macrocode} % -% Define |\newdateformat| which defines a declaration that redefines |\formatdate| so that -% it uses |\dateformat|. |\dateformat| takes four arguments, the first defines the format -% the last three arguments are the three arguments that effectively get passed to |\formatdate|. -% |\dateformat| sets |\@day|, |\@month| and |\@year|. |\c@DAY|, |\c@MONTH| and |\c@YEAR| -% are set as synonims for |\@day|, |\@month| and |\@year|, to that the uses can use the counters -% |DAY|, |MONTH| and |YEAR| as part of the format. -% \begin{macrocode} -\if@dt@nodate -\PackageInfo{datetime}{option "nodate" used, so not -defining \string\newdateformat} -\else -% \end{macrocode} -% The commands |\THEDAY|, |\THEMONTH| and |\THEYEAR| should only be -% used in the argument to |\newdateformat|. This is done partly to -% assist the \LaTeX2HTML version. -% \begin{macrocode} -\providecommand*\THEDAY{\the\@day} -\providecommand*\THEMONTH{\the\@month} -\providecommand*\THEYEAR{\the\@year} -% \end{macrocode} -% Simulate a \LaTeX\ counter. -% \begin{macrocode} -\let\c@DAY=\@day -\let\c@MONTH=\@month -\let\c@YEAR=\@year -% \end{macrocode} -%\begin{macro}{\dateformat} -% Format the given date in the given format. -% \begin{macrocode} -\providecommand*{\dateformat}[4]{% -\@day=#2\relax\@month=#3\relax\@year=#4\relax#1} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\newdateformat} -% Provide a means to define a new date format. -%\changes{2.2}{2004/04/27}{new} -% \begin{macrocode} -\providecommand{\newdateformat}[2]{% -\@ifundefined{#1}{% -\expandafter\DeclareRobustCommand\csname#1\endcsname{% -\renewcommand{\formatdate}{\dateformat{#2}}}}{% -\PackageError{datetime}{Can't create new date format, command -\textbackslash#1 already defined}{You will need to -give your new date format a different name}}} -% \end{macrocode} -%\end{macro} -% End of |\if@no@date| else part: -% \begin{macrocode} -\fi -% \end{macrocode} -% -% \subsubsection{Time Macros} -% Define a command to create a new time format, similar to the new -% date format. Again this is done in a way that makes it easier to -% code the \LaTeX2HTML version. -% \begin{macrocode} -\newcount\c@HOUR -\newcount\c@HOURXII -\newcount\c@MINUTE -\newcount\c@TOHOUR -\newcount\c@TOMINUTE -% \end{macrocode} -% These commands should only be used in |\newtimeformat|. -% \begin{macrocode} -\def\THEHOUR{\the\c@HOUR} -\def\THEHOURXII{\the\c@HOURXII} -\def\THEMINUTE{\the\c@MINUTE} -\def\THETOHOUR{\the\c@TOHOUR} -\def\THETOMINUTE{\the\c@TOMINUTE} -% \end{macrocode} -%\begin{macro}{\newtimeformat} -% Provide a means to define a new time format. -%\changes{2.3}{2004/05/01}{new} -% \begin{macrocode} -\providecommand*{\newtimeformat}[2]{% -\@ifundefined{#1}{% -\expandafter\def\csname#1\endcsname{% -\c@HOUR=\time% -\divide\c@HOUR by 60\relax -\c@HOURXII=\c@HOUR -\ifnum\c@HOURXII>12 -\advance\c@HOURXII by -12\relax -\fi -\c@MINUTE=\time% -\@modulo{\c@MINUTE}{60}% -\c@TOHOUR=\c@HOURXII -\advance\c@TOHOUR by 1\relax -\@modulo{\c@TOHOUR}{12}% -\c@TOMINUTE=\c@MINUTE -\advance\c@TOMINUTE by -60\relax -\multiply\c@TOMINUTE by -1\relax -#2\relax -}}{% -\PackageError{datetime}{Command \textbackslash#1 already defined}{% -You can't create a new time format called "#1" as the command -\textbackslash#1 already exists}}} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\xxivtime} -% Define commands to print the current time. Twenty-four hour time: -% \begin{macrocode} -\newtimeformat{xxivtime}{% -\twodigit\THEHOUR\timeseparator\twodigit\THEMINUTE} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\ampmtime} -% 12-hour time: -%\changes{2.3}{2004/05/01}{fixed minor bug} -%\changes{2.51}{2007/01/30}{fixed bug between midnight and 1am} -% \begin{macrocode} -\newtimeformat{ampmtime}{% -\ifthenelse{\value{HOUR}=0}{12}{\THEHOURXII}\timeseparator -\twodigit\THEMINUTE -\ifthenelse{\value{HOUR}<12}{\amname}{% -\ifthenelse{\time=720}{ \noon}{\pmname}}} -% \end{macrocode} -%\end{macro} -% Textual time: -%\begin{macro}{\hourstring} -% \cs{hourstring}\marg{count} will print |\midnight| if -% \meta{count} is 0, otherwise will do \cs{Numberstring}\marg{count}. -% \begin{macrocode} -\newcommand*{\hourstring}[1]{% -\ifthenelse{\value{#1}=0}{\midnight}{\Numberstring{#1}}} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\oclock} -%\changes{2.43}{2005/02/23}{fixed bug causing an infinite loop on the hour} -% \begin{macrocode} -\newtimeformat{oclock}{\ifthenelse{\time=0 \or \time=720}{% -% \end{macrocode} -% Midnight or Midday: -% \begin{macrocode} -\ifthenelse{\time=0}{\midnight}{\noon}}{% -% \end{macrocode} -% Neither Midnight nor Midday. -% Do minutes first -% \begin{macrocode} -\ifthenelse{\value{MINUTE}=0}{% -% \end{macrocode} -% On the hour: don't print any minutes, just do the hour and -% |\oclockstring| -% \begin{macrocode} -\Numberstring{HOUR} \oclockstring}{% -\ifthenelse{\value{MINUTE}=15}{% -\quarterpast\ \hourstring{HOUR}}{% -\ifthenelse{\value{MINUTE}=30}{% -\halfpast\ \hourstring{HOUR}}{% -\ifthenelse{\value{MINUTE}=45}{% -\quarterto\ \hourstring{TOHOUR}}{% -\ifthenelse{\value{MINUTE}<30}{% -\Numberstring{MINUTE}\ \ifthenelse{\value{MINUTE}=1}{minute}{minutes} -past \hourstring{HOURXII}}{% -\Numberstring{TOMINUTE}\ \ifthenelse{% -\value{TOMINUTE}=1}{minute}{minutes} to \hourstring{TOHOUR}}}}}}% -% \end{macrocode} -% Now say whether it is morning or afternoon -% \begin{macrocode} -\ifthenelse{\value{HOUR}<12}{% -% \end{macrocode} -% Morning -% \begin{macrocode} -\ifthenelse{\value{HOUR}=0}{}{\ \amstring}}{% -% \end{macrocode} -% Afternoon -% \begin{macrocode} -\ifthenelse{\value{TOHOUR}=0}{}{\ \pmstring}}}} -% \end{macrocode} -%\end{macro} -% Define textual strings used in the above. -%\begin{macro}{\amname} -% \begin{macrocode} -\providecommand*{\amname}{am} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\pmname} -% \begin{macrocode} -\providecommand*{\pmname}{pm} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\amorpmname} -% \begin{macrocode} -\providecommand*{\amorpmname}{% -\ifthenelse{\value{HOUR}>12}{\pmname}{\amname}} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\amstring} -% \begin{macrocode} -\providecommand*{\amstring}{in the morning} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\pmstring} -% \begin{macrocode} -\providecommand*{\pmstring}{in the afternoon} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\amorpmstring} -% \begin{macrocode} -\providecommand*{\amorpmstring}{% -\ifthenelse{\value{HOUR}>12}{\pmstring}{\amstring}} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\halfpast} -% \begin{macrocode} -\providecommand*{\halfpast}{Half past} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\quarterpast} -% \begin{macrocode} -\providecommand*{\quarterpast}{Quarter past} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\quarterto} -% \begin{macrocode} -\providecommand*{\quarterto}{Quarter to} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\noon} -% \begin{macrocode} -\providecommand*{\noon}{Noon} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\midnight} -% \begin{macrocode} -\providecommand*{\midnight}{Midnight} -% \end{macrocode} -%\end{macro} -%\begin{macro}{\oclockstring} -% \begin{macrocode} -\providecommand*{\oclockstring}{O'Clock} -% \end{macrocode} -%\end{macro} %\begin{macro}{\pdfdate} % Finally create command that will typeset the date in PDF format % e.g. 20040501215500. This is defined regardless of |\if@no@date| % as it's provided for use in |\pdfinfo|. Initially |\pdfdate| is set -% to the year. +% to the year. Note that pdftex provides \cs{pdfcreationdate} +% which also stores the seconds and time zone. %\changes{2.31}{2004/05/01}{new} %\changes{2.32}{2004/05/04}{fixed bug} % \begin{macrocode} @@ -1733,8 +2016,7 @@ past \hourstring{HOURXII}}{% \edef\pdfdate{\the\dt@b\the\dt@a} \fi % \end{macrocode} -% Append the seconds. \TeX\ doesn't store the seconds, so -% set to zero. +% Append the seconds. % \begin{macrocode} \dt@a={00} \dt@b=\expandafter{\pdfdate} @@ -1748,6 +2030,30 @@ past \hourstring{HOURXII}}{% %\fi %\iffalse % \begin{macrocode} +%<*dt-american.def> +% \end{macrocode} +%\fi +%\subsubsection{american} +% Identify file +% \begin{macrocode} +\ProvidesFile{dt-american.def}[2007/06/11] +% \end{macrocode} +\let\dateamerican\usdate + +\let\monthnameamerican\monthnameenglish +\let\shortmonthnameamerican\shortmonthnameenglish + +\let\dayofweeknameidamerican\dayofweeknameidenglish +\let\shortdayofweeknameidamerican\shortdayofweeknameidenglish + +\newcommand*{\ordinaldateamerican}[1]{#1} +%\iffalse +% \begin{macrocode} +%</dt-american.def> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} %<*dt-austrian.def> % \end{macrocode} %\fi @@ -1944,6 +2250,13 @@ Month numbers should go from 1 (urtarrilaren) to 12 (abenduaren)}% % \begin{macrocode} \ProvidesFile{dt-breton.def}[2004/10/31] % \end{macrocode} +%\begin{macro}{\ordinaldatebreton} +% Breton version: +% \begin{macrocode} +\newcommand*{\ordinaldatebreton}[1]{% +#1\ifnum#1=1\/\textsuperscript{a\~n}\fi} +% \end{macrocode} +%\end{macro} % Define month names. % \begin{macrocode} \providecommand{\monthnamebreton}[1][\month]{% @@ -2025,6 +2338,8 @@ Month numbers should go from 1 (Genver) to 12 (Kerzu)}% \let\dayofweeknameidbritish\dayofweeknameidenglish \let\shortdayofweeknameidbritish\shortdayofweeknameidenglish + +\let\ordinaldatebritish\ordinaldateenglish %\iffalse % \begin{macrocode} %</dt-british.def> @@ -2557,6 +2872,21 @@ Month numbers should go from 1 to 12}% % \begin{macrocode} \ProvidesFile{dt-french.def}[2004/10/31] % \end{macrocode} +%\begin{macro}{\ordinaldatefrench} +% French: +% \begin{macrocode} +\newcommand*{\ordinaldatefrench}[1]{% +#1\ifnum#1=1\ier\fi} +% \end{macrocode} +%\end{macro} +%\begin{macro}{\ier} +% In case \verb|\ier| hasn't been defined:% +%\changes{v2.47}{27 Oct 2005}{defined if it doesn't +% already exist} +% \begin{macrocode} +\providecommand*{\ier}{\textsuperscript{er}} +% \end{macrocode} +%\end{macro} % Define week day names. % \begin{macrocode} \providecommand{\dayofweeknameidfrench}[1]{% @@ -2908,18 +3238,63 @@ Month numbers should go from 1 to 12}% %<*dt-italian.def> % \end{macrocode} %\fi -%\subsubsection{Italian} -% Identify file -% \begin{macrocode} -\ProvidesFile{dt-italian.def}[2004/10/31] -% \end{macrocode} -% Define month names. -% \begin{macrocode} +%% +%% This is file `dt-italian.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% datetime.dtx (with options: `dt-italian.def,package') +%% Copyright (C) 2005 Nicola Talbot, all rights reserved. +%% If you modify this file, you must change its name first. +%% You are NOT ALLOWED to distribute this file alone. You are NOT +%% ALLOWED to take money for the distribution or use of either this +%% file or a changed version, except for a nominal charge for copying +%% etc. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\ProvidesFile{dt-italian.def}[2008/01/22] + +% translations provided by Giada Ermacora +\providecommand{\dayofweeknameiditalian}[1]{% +\ifcase#1\relax +\or domenica% +\or luned\`{\i}% +\or marted\`{\i}% +\or mercoled\`{\i}% +\or gioved\`{\i}% +\or venerd\`{\i}% +\or sabato% +\fi} + +\providecommand{\shortdayofweeknameiditalian}[1]{% +\ifcase#1\relax +\or dom% +\or lun% +\or mar% +\or mer% +\or gio% +\or ven% +\or sab% +\fi} + \providecommand{\monthnameitalian}[1][\month]{% \@orgargctr=#1\relax \ifcase\@orgargctr -\PackageError{datetime}{Invalid Month number \the\@orgargctr}{% -Month numbers should go from 1 to 12}% +\PackageError{datetime}{Invalid Month number \the\@orgargctr}{Month numbers should go from 1 (gennaio) to 12 (dicembre)}% \or gennaio% \or febbraio% \or marzo% @@ -2932,18 +3307,36 @@ Month numbers should go from 1 to 12}% \or ottobre% \or novembre% \or dicembre% -\else -\PackageError{datetime}{Invalid Month number \the\@orgargctr}{% -Month numbers should go from 1 to 12}% +\else \PackageError{datetime}{Invalid Month number \the\@orgargctr}{Month numbers should go from 1 (gennaio) to 12 (dicembre)}% \fi} -% \end{macrocode} -% (Re)Define declaration to switch to this format. -% \begin{macrocode} + +\providecommand{\shortmonthnameitalian}[1][\month]{% +\@orgargctr=#1\relax +\ifcase\@orgargctr +\PackageError{datetime}{Invalid Month number \the\@orgargctr}{Month numbers should go from 1 (gen) to 12 (dic)}% +\or gen% +\or feb% +\or mar% +\or apr% +\or mag% +\or giu% +\or lug% +\or ago% +\or set% +\or ott% +\or nov% +\or dic% +\else% +\PackageError{datetime}{Invalid Month number \the\@orgargctr}{Month numbers should go from 1 (gen) to 12 (dic)}% +\fi} + \DeclareRobustCommand*\dateitalian{% \renewcommand{\formatdate}[3]{% \@day=##1\relax\@month=##2\relax\@year=##3\relax \number\@day\space\monthnameitalian[\@month]\space\number\@year}} -% \end{macrocode} +\endinput +%% +%% End of file `dt-italian.def'. %\iffalse % \begin{macrocode} %</dt-italian.def> @@ -3915,6 +4308,8 @@ Month numbers should go from 1 to 12}% \let\dayofweeknameidUKenglish\dayofweeknameidenglish \let\shortdayofweeknameidUKenglish\shortdayofweeknameidenglish + +\let\ordinaldateUKenglish\ordinaldateenglish %\iffalse % \begin{macrocode} %</dt-UKenglish.def> @@ -3982,6 +4377,8 @@ Month numbers should go from 1 to 12}% \let\dayofweeknameidUSenglish\dayofweeknameidenglish \let\shortdayofweeknameidUSenglish\shortdayofweeknameidenglish + +\newcommand*{\ordinaldateUSenglish}[1]{#1} %\iffalse % \begin{macrocode} %</dt-USenglish.def> @@ -4079,6 +4476,13 @@ Month numbers should go from 1 to 12}% % \begin{macrocode} \ProvidesFile{dt-welsh.def}[2004/10/31] % \end{macrocode} +%\begin{macro}{\ordinaldatewelsh} +% Welsh version: +% \begin{macrocode} +\newcommand*{\ordinaldatewelsh}[1]{% +#1\ifnum#1=1\/\textsuperscript{a\~n}\fi} +% \end{macrocode} +%\end{macro} % Define month names. % \begin{macrocode} \providecommand{\monthnamewelsh}[1][\month]{% diff --git a/Master/texmf-dist/source/latex/datetime/datetime.ins b/Master/texmf-dist/source/latex/datetime/datetime.ins index ab67202ba1a..84830ffae77 100644 --- a/Master/texmf-dist/source/latex/datetime/datetime.ins +++ b/Master/texmf-dist/source/latex/datetime/datetime.ins @@ -1,10 +1,10 @@ -% datetime.ins generated using makedtx version 0.94b 2007/8/20 15:37 +% datetime.ins generated using makedtx version 0.94b 2009/11/17 22:04 \input docstrip \preamble datetime.dtx - Copyright 2007 Nicola Talbot + Copyright 2009 Nicola Talbot This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 @@ -18,7 +18,7 @@ The Current Maintainer of this work is Nicola Talbot. - This work consists of the files datetime.dtx and datetime.ins and the derived files datetime.sty, dt-austrian.def, dt-bahasa.def, dt-basque.def, dt-breton.def, dt-british.def, dt-bulgarian.def, dt-catalan.def, dt-croatian.def, dt-czech.def, dt-danish.def, dt-dutch.def, dt-esperanto.def, dt-estonian.def, dt-finnish.def, dt-french.def, dt-galician.def, dt-german.def, dt-greek.def, dt-hebrew.def, dt-icelandic.def, dt-irish.def, dt-italian.def, dt-latin.def, dt-lsorbian.def, dt-magyar.def, dt-naustrian.def, dt-ngerman.def, dt-norsk.def, dt-polish.def, dt-portuges.def, dt-romanian.def, dt-russian.def, dt-samin.def, dt-scottish.def, dt-serbian.def, dt-slovak.def, dt-slovene.def, dt-spanish.def, dt-swedish.def, dt-turkish.def, dt-UKenglish.def, dt-ukraineb.def, dt-USenglish.def, dt-usorbian.def, dt-welsh.def. + This work consists of the files datetime.dtx and datetime.ins and the derived files datetime.sty, dt-american.def, dt-austrian.def, dt-bahasa.def, dt-basque.def, dt-breton.def, dt-british.def, dt-bulgarian.def, dt-catalan.def, dt-croatian.def, dt-czech.def, dt-danish.def, dt-dutch.def, dt-esperanto.def, dt-estonian.def, dt-finnish.def, dt-french.def, dt-galician.def, dt-german.def, dt-greek.def, dt-hebrew.def, dt-icelandic.def, dt-irish.def, dt-italian.def, dt-latin.def, dt-lsorbian.def, dt-magyar.def, dt-naustrian.def, dt-ngerman.def, dt-norsk.def, dt-polish.def, dt-portuges.def, dt-romanian.def, dt-russian.def, dt-samin.def, dt-scottish.def, dt-serbian.def, dt-slovak.def, dt-slovene.def, dt-spanish.def, dt-swedish.def, dt-turkish.def, dt-UKenglish.def, dt-ukraineb.def, dt-USenglish.def, dt-usorbian.def, dt-welsh.def. \endpreamble @@ -26,6 +26,8 @@ \generate{\file{datetime.sty}{\usepreamble\defaultpreamble \usepostamble\defaultpostamble\from{datetime.dtx}{datetime.sty,package}} +\file{dt-american.def}{\usepreamble\defaultpreamble +\usepostamble\defaultpostamble\from{datetime.dtx}{dt-american.def,package}} \file{dt-austrian.def}{\usepreamble\defaultpreamble \usepostamble\defaultpostamble\from{datetime.dtx}{dt-austrian.def,package}} \file{dt-bahasa.def}{\usepreamble\defaultpreamble diff --git a/Master/texmf-dist/source/latex/datetime/datetime.perl b/Master/texmf-dist/source/latex/datetime/datetime.perl new file mode 100644 index 00000000000..86a7646b0fa --- /dev/null +++ b/Master/texmf-dist/source/latex/datetime/datetime.perl @@ -0,0 +1,2002 @@ +# File : datetime.perl +# Author : Nicola Talbot +# Date : 17 Nov 2009 +# Version : 1.04 +# +# This is a LaTeX2HTML style implementing the datetime package, and +# is distributed as part of that package. +# Copyright 2007 Nicola L.C. Talbot +# This work may be distributed and/or modified under the +# conditions of the LaTeX Project Public License, either version 1.3 +# of this license of (at your option) any later version. +# The latest version of this license is in +# http://www.latex-project.org/lppl.txt +# and version 1.3 or later is part of all distributions of LaTeX +# version 2005/12/01 or later. +# +# This work has the LPPL maintenance status `maintained'. +# +# The Current Maintainer of this work is Nicola Talbot. + +# set up default values for internal counters. + +($global{SECONDS},$global{MINUTE},$global{HOUR},$global{DAY},$global{MONTH},$global{YEAR})=localtime(time); +$global{YEAR} += 1900; +$global{MONTH}++; + +package main; + +&do_require_package('fmtcount'); + +sub do_cmd_ordinaldate{ + &do_cmd_ordinalnum(@_); +} + +# define package options + +sub do_datetime_long{ + &do_cmd_longdate(@_); +} + +sub do_datetime_short{ + &do_cmd_shortdate(@_); +} + +sub do_datetime_text{ + &do_cmd_textdate(@_); +} + +sub do_datetime_yyyymmdd{ + &do_cmd_yyyymmdddate(@_); +} + +sub do_datetime_ddmmyyyy{ + &do_cmd_ddmmyyyydate(@_); +} + +sub do_datetime_dmyyyy{ + &do_cmd_dmyyyydate(@_); +} + +sub do_datetime_ddmmyy{ + &do_cmd_ddmmyydate(@_); +} + +sub do_datetime_dmyy{ + &do_cmd_dmyyyydate(@_); +} + +sub do_datetime_us{ + &do_cmd_usdate(@_); +} + +sub do_datetime_mmddyyyy{ + &do_cmd_mmddyyyydate(@_); +} + +sub do_datetime_mdyyyy{ + &do_cmd_mdyyyydate(@_); +} + +sub do_datetime_mmddyy{ + &do_cmd_mmddyydate(@_); +} + +sub do_datetime_mdyy{ + &do_cmd_mdyyyydate(@_); +} + +sub do_datetime_raise{ + local($tmp)=""; + + $tmp .= 'sub do_cmd_fmtord{'; + $tmp .= 'local($_) = @_;'; + $tmp .= 'local($num) = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($num=$2));'; + $tmp .= 'join("", "<SUP>",$num,"</SUP>",$_);'; + $tmp .='}'; + + eval($tmp); +} + +sub do_datetime_level{ + local($tmp)=""; + + $tmp .= 'sub do_cmd_fmtord{'; + $tmp .= 'local($_) = @_;'; + $tmp .= 'local($num) = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($num=$2));'; + $tmp .= 'join("", $num,$_);'; + $tmp .='}'; + + eval($tmp); +} + +sub do_datetime_dayofweek{ + &do_cmd_showdowtrue(@_); +} + +sub do_datetime_nodayofweek{ + &do_cmd_showdowfalse(@_); +} + +sub do_datetime_hhmmss{ + &set_timeformat_hhmmsstime +} + +sub do_datetime_24hr{ + &set_timeformat_xxivtime +} + +&do_datetime_24hr; + +sub do_datetime_12hr{ + &set_timeformat_ampmtime +} + +sub do_datetime_oclock{ + &set_timeformat_oclock +} + +sub do_datetime_iso{ + &set_timeformat_hhmmsstime; + &do_cmd_yyyymmdddate; + eval('sub do_cmd_dateseparator{join(\'\', \'-\', $_[0]);}'); + eval('sub do_cmd_timeseparator{join(\'\', \':\', $_[0]);}'); +} + +# babel stuff (Month will already be redefined by babel, so only need to change $dateformat) + +sub do_datetime_austrian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateaustrian{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateaustrian(@_); +} + +if (defined &austrian_today) +{ + &do_datetime_austrian(@_); +} + +sub do_datetime_bahasa{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datebahasa{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datebahasa(@_); +} + +if (defined &bahasa_today) +{ + &do_datetime_bahasa(@_); +} + +sub do_datetime_basque{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datebasque{'; + $tmp .= ' $dateformat = "THEYEAR.eko MONTHNAME[THEMONTH] THEDAY";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datebasque(@_); +} + +if (defined &basque_today) +{ + &do_datetime_basque(@_); +} + +sub do_datetime_breton{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datebreton{'; + $tmp .= ' $dateformat = "{ORDINALDATE{DAY}}\\ a viz MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + $tmp = 'sub do_cmd_ordinaldate{'; + $tmp .= 'local($_) = @_;'; + $tmp .= 'local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2));'; + $tmp .= 'local($before) = $num;'; + + $tmp .= 'if ($num == 1)'; + $tmp .= '{ $before .= \'a\~n\'; }'; + + $tmp .= '$before . $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datebreton(@_); +} + +if (defined &breton_today) +{ + &do_datetime_breton(@_); +} + +sub do_datetime_bulgarian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datebulgarian{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR \\cyrg.";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datebulgarian(@_); +} + +if (defined &bulgarian_today) +{ + &do_datetime_bulgarian(@_); +} + +sub do_datetime_catalan{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datecatalan{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] de THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datecatalan(@_); +} + +if (defined &catalan_today) +{ + &do_datetime_catalan(@_); +} + +sub do_datetime_croatian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datecroatian{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR.";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datecroatian(@_); +} + +if (defined &croatian_today) +{ + &do_datetime_croatian(@_); +} + +sub do_datetime_czech{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateczech{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateczech(@_); +} + +if (defined &czech_today) +{ + &do_datetime_czech(@_); +} + +sub do_datetime_danish{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datedanish{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datedanish(@_); +} + +if (defined &danish_today) +{ + &do_datetime_danish(@_); +} + +sub do_datetime_dutch{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datedutch{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datedutch(@_); +} + +if (defined &dutch_today) +{ + &do_datetime_dutch(@_); +} + +sub do_datetime_esperanto{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateesperanto{'; + $tmp .= ' $dateformat = "THEDAY--a de MONTHNAME[THEMONTH], THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateesperanto(@_); +} + +if (defined &esperanto_today) +{ + &do_datetime_esperanto(@_); +} + +sub do_datetime_estonian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateestonian{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR. a.";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateestonian(@_); +} + +if (defined &estonian_today) +{ + &do_datetime_estonian(@_); +} + +sub do_datetime_finnish{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datefinnish{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datefinnish(@_); +} + +if (defined &finnish_today) +{ + &do_datetime_finnish(@_); +} + +sub do_datetime_french{ + local($tmp) = ""; + + eval($tmp); + $tmp .= 'sub do_cmd_datefrench{'; + $tmp .= ' $dateformat = "{ORDINALDATE{DAY}}\\ MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + $tmp = 'sub do_cmd_ordinaldate{'; + $tmp .= 'local($_) = @_;'; + $tmp .= 'local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2));'; + $tmp .= 'local($before) = $num;'; + + $tmp .= 'if ($num == 1)'; + $tmp .= '{ $before .= \'\ier\'; }'; + + $tmp .= '$before . $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datefrench(@_); +} + +if (defined &french_today) +{ + &do_datetime_french(@_); +} + +sub do_datetime_galician{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dategalician{'; + $tmp .= ' $dateformat = "THEDAY de MONTHNAME[THEMONTH] de THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dategalician(@_); +} + +if (defined &galician_today) +{ + &do_datetime_galician(@_); +} + +sub do_datetime_german{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dategerman{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dategerman(@_); +} + +if (defined &german_today) +{ + &do_datetime_german(@_); +} + +sub do_datetime_greek{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dategreek{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dategreek(@_); +} + +if (defined &greek_today) +{ + &do_datetime_greek(@_); +} + +sub do_datetime_icelandic{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateicelandic{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateicelandic(@_); +} + +if (defined &icelandic_today) +{ + &do_datetime_icelandic(@_); +} + +sub do_datetime_irish{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateirish{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateirish(@_); +} + +if (defined &irish_today) +{ + &do_datetime_irish(@_); +} + +sub do_datetime_italian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateitalian{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateitalian(@_); +} + +if (defined &italian_today) +{ + &do_datetime_italian(@_); +} + +sub do_datetime_latin{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datelatin{'; + $tmp .= ' $dateformat = "ROMANNUMERALU{THEDAY} MONTHNAME[THEMONTH] ROMANNUMERALU{THEYEAR}";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datelatin(@_); +} + +if (defined &latin_today) +{ + &do_datetime_latin(@_); +} + +sub do_datetime_lsorbian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datelsorbian{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datelsorbian(@_); +} + +if (defined &lsorbian_today) +{ + &do_datetime_lsorbian(@_); +} + +sub do_datetime_magyar{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datemagyar{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR.";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datemagyar(@_); +} + +if (defined &magyar_today) +{ + &do_datetime_magyar(@_); +} + +sub do_datetime_naustrian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datenaustrian{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datenaustrian(@_); +} + +if (defined &naustrian_today) +{ + &do_datetime_naustrian(@_); +} + +sub do_datetime_ngerman{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datengerman{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datengerman(@_); +} + +if (defined &ngerman_today) +{ + &do_datetime_ngerman(@_); +} + +sub do_datetime_norsk{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datenorsk{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datenorsk(@_); +} + +if (defined &norsk_today) +{ + &do_datetime_norsk(@_); +} + +sub do_datetime_polish{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datenorsk{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datenorsk(@_); +} + +if (defined &polish_today) +{ + &do_datetime_polish(@_); +} + +sub do_datetime_portuges{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateportuges{'; + $tmp .= ' $dateformat = "THEDAY de MONTHNAME[THEMONTH] de THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateportuges(@_); +} + +if (defined &portuges_today) +{ + &do_datetime_portuges(@_); +} + +sub do_datetime_romanian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateromanian{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateromanian(@_); +} + +if (defined &romanian_today) +{ + &do_datetime_romanian(@_); +} + +sub do_datetime_russian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_daterussian{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR \\\\cyrg.";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_daterussian(@_); +} + +if (defined &russian_today) +{ + &do_datetime_russian(@_); +} + +sub do_datetime_samin{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datesamin{'; + $tmp .= ' $dateformat = "MONTHNAME[THEMONTH] THEDAY.~b. THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datesamin(@_); +} + +if (defined &samin_today) +{ + &do_datetime_samin(@_); +} + +sub do_datetime_scottish{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datescottish{'; + $tmp .= ' $dateformat = "THEDAY MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datescottish(@_); +} + +if (defined &scottish_today) +{ + &do_datetime_scottish(@_); +} + +sub do_datetime_serbian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateserbian{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateserbian(@_); +} + +if (defined &serbian_today) +{ + &do_datetime_serbian(@_); +} + +sub do_datetime_slovak{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateslovak{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateslovak(@_); +} + +if (defined &slovak_today) +{ + &do_datetime_slovak(@_); +} + +sub do_datetime_slovene{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateslovene{'; + $tmp .= ' $dateformat = "THEDAY. MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateslovene(@_); +} + +if (defined &slovene_today) +{ + &do_datetime_slovene(@_); +} + +sub do_datetime_spanish{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datespanish{'; + $tmp .= ' $dateformat = "THEDAY~de MONTHNAME[THEMONTH] de~THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datespanish(@_); +} + +if (defined &spanish_today) +{ + &do_datetime_spanish(@_); +} + +sub do_datetime_swedish{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateswedish{'; + $tmp .= ' $dateformat = "THEDAY~MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + $tmp = ""; + $tmp .= 'sub do_cmd_datesymd{'; + $tmp .= ' $dateformat = "THEYEAR-TWODIGIT{THEMONTH}-TWODIGIT{THEDAY}";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + $tmp = ""; + $tmp .= 'sub do_cmd_datesdmy{'; + $tmp .= ' $dateformat = "THEDAY/THEMONTH THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateswedish(@_); +} + +if (defined &swedish_today) +{ + &do_datetime_swedish(@_); +} + +sub do_datetime_turkish{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateturkish{'; + $tmp .= ' $dateformat = "THEDAY~MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateturkish(@_); +} + +if (defined &turkish_today) +{ + &do_datetime_turkish(@_); +} + +sub do_datetime_ukraineb{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateukraineb{'; + $tmp .= ' $dateformat = "THEDAY~MONTHNAME[THEMONTH] THEYEAR~\\\\cyrr.";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateukraineb(@_); +} + +if (defined &ukraineb_today) +{ + &do_datetime_ukraineb(@_); +} + +sub do_datetime_usorbian{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_dateusorbian{'; + $tmp .= ' $dateformat = "THEDAY.~MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_dateusorbian(@_); +} + +if (defined &usorbian_today) +{ + &do_datetime_usorbian(@_); +} + +sub do_datetime_welsh{ + local($tmp) = ""; + + $tmp .= 'sub do_cmd_datewelsh{'; + $tmp .= ' $dateformat = "{ORDINALDATE{DAY}}\\ a viz MONTHNAME[THEMONTH] THEYEAR";'; + $tmp .= ' $_[0];'; + $tmp .= '}'; + + eval($tmp); + + $tmp = 'sub do_cmd_ordinaldate{'; + $tmp .= 'local($_) = @_;'; + $tmp .= 'local($num) = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($num=$2));'; + $tmp .= 'local($before) = $num;'; + + $tmp .= 'if ($num == 1)'; + $tmp .= '{ $before .= \'a\~n\'; }'; + + $tmp .= '$before . $_[0];'; + $tmp .= '}'; + + eval($tmp); + + &do_cmd_datewelsh(@_); +} + +if (defined &welsh_today) +{ + &do_datetime_welsh(@_); +} + +# As far as I know, LaTeX2HTML doesn't implement TeX conditionals. +# $showdow corresponds to LaTeX boolean variable showdow +$showdow = 1; + +sub get_monthname{ + local($month) = @_; + + if ($month eq 'THEMONTH' or $month eq '\THEMONTH') + { + # this is a cludge to help newdateformat work + + 'MONTHNAME[THEMONTH]'; + } + else + { + if ($month eq '') + { + local($today) = &get_date(); + $today =~ m|(\d+)/0?(\d+)/|; + $month = $1; + } + + $Month[$month]; + } +} + +sub do_cmd_monthname{ + local($_) = @_; + local($month,$pat) = &get_next_optional_argument; + + local($monthname) = &get_monthname($month); + join('',$monthname,$_); +} + +sub get_shortmonthname{ + local($month) = @_; + + if ($month eq 'THEMONTH' or $month eq '\THEMONTH') + { + 'SHORTMONTHNAME[THEMONTH]'; + } + else + { + substr(&get_monthname($month), 0, 3); + } +} + +sub do_cmd_shortmonthname{ + local($_) = @_; + local($month,$pat) = &get_next_optional_argument; + + local($monthname) = &get_shortmonthname($month); + + join('',$monthname,$_); +} + +sub is_leap_year{ + local($year) = @_; + local($isleapyear) = 0; + + if (($year%400) == 0) + { + # year mod 400 = 0 => leap year + + $isleapyear = 1; + } + elsif (($year%100) == 0) + { + # year mod 100 = 0 and year mod 400 != 0 => not a leap year + + $isleapyear = 0; + } + elsif (($year%4) == 0) + { + # year mod 4 = 0 and year mod 100 != 0 => leap year + + $isleapyear = 1; + } + + $isleapyear; +} + +sub get_day_of_year{ + local($day,$month,$year) = @_; + local($dayofyear) = 0; + + SWITCH: { + if ($month == 2) {$dayofyear += 31; last SWITCH; } + if ($month == 3) {$dayofyear += 59; last SWITCH; } + if ($month == 4) {$dayofyear += 90; last SWITCH; } + if ($month == 5) {$dayofyear += 120; last SWITCH; } + if ($month == 6) {$dayofyear += 151; last SWITCH; } + if ($month == 7) {$dayofyear += 181; last SWITCH; } + if ($month == 8) {$dayofyear += 212; last SWITCH; } + if ($month == 9) {$dayofyear += 243; last SWITCH; } + if ($month == 10) {$dayofyear += 273; last SWITCH; } + if ($month == 11) {$dayofyear += 304; last SWITCH; } + if ($month == 12) {$dayofyear += 334; last SWITCH; } + } + + if ($month > 2 && &is_leap_year($year)) + { + $dayofyear += 1; + } + + $dayofyear += $day; + local($_)=$dayofyear; +} + +sub get_day_of_week{ + local($day,$month,$year) = @_; + local($dayofyear) = &get_day_of_year($day,$month,$year); + local($_) = (((($year-1901)%28)*1.25 + 2)%7 + $dayofyear - 1)%7 + 1; +} + +sub get_day_of_weekname_english{ + local($dow) = @_; + + local(@DayOfWeek) = ('Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday'); + + if ($dow <= 0 || $dow > 7) + { + &write_warnings("Invalid day of week number: $dow"); + } + else + { + $DayOfWeek[$dow-1]; + } +} + +sub get_day_of_weekname_french{ + local($dow) = @_; + + local(@DayOfWeek) = ('dimanche', + 'lundi', + 'mardi', + 'mercredi', + 'jeudi', + 'vendredi', + 'samedi'); + + if ($dow <= 0 || $dow > 7) + { + &write_warnings("Invalid day of week number: $dow"); + } + else + { + $DayOfWeek[$dow-1]; + } +} + +sub get_day_of_weekname_spanish{ + local($dow) = @_; + + local(@DayOfWeek) = ('domingo', + 'lunes', + 'martes', + 'mi\\\'ercoles', + 'jueves', + 'viernes', + 's\\\'abado'); + + if ($dow <= 0 || $dow > 7) + { + &write_warnings("Invalid day of week number: $dow"); + } + else + { + $DayOfWeek[$dow-1]; + } +} + +sub get_day_of_weekname_portuges{ + local($dow) = @_; + + local(@DayOfWeek) = ('domingo', + 'segunda-feira', + 'ter\c{c}a-feira', + 'quarta-feira', + 'quinta-feira', + 'sexta-feira', + 'sabado'); + + if ($dow <= 0 || $dow > 7) + { + &write_warnings("Invalid day of week number: $dow"); + } + else + { + $DayOfWeek[$dow-1]; + } +} + +sub get_day_of_weekname_german{ + local($dow) = @_; + + local(@DayOfWeek) = ('Sonntag', + 'Montag', + 'Dienstag', + 'Mittwoch', + 'Donnerstag', + 'Freitag', + 'Samstag'); + + if ($dow <= 0 || $dow > 7) + { + &write_warnings("Invalid day of week number: $dow"); + } + else + { + $DayOfWeek[$dow-1]; + } +} + +sub get_day_of_weekname_ngerman{ + local($dow) = @_; + + local(@DayOfWeek) = ('Sonntag', + 'Montag', + 'Dienstag', + 'Mittwoch', + 'Donnerstag', + 'Freitag', + 'Samstag'); + + if ($dow <= 0 || $dow > 7) + { + &write_warnings("Invalid day of week number: $dow"); + } + else + { + $DayOfWeek[$dow-1]; + } +} + +sub get_day_of_weekname{ + local($dow)=@_; + local($dowsub); + + $dowsub = "get_day_of_weekname_$default_language"; + + if (defined ($dowsub)) + { + &$dowsub($dow); + } + else + { + &get_day_of_weekname_english($dow); + } +} + +sub get_short_day_of_weekname_english{ + local($dow) = @_; + + local(@DayOfWeek) = ('Sun', + 'Mon', + 'Tue', + 'Wed', + 'Thu', + 'Fri', + 'Sat'); + + if ($dow <= 0 || $dow > 7) + { + &write_warnings("Invalid day of week number: $dow"); + } + else + { + $DayOfWeek[$dow-1]; + } +} + +sub get_short_day_of_weekname_german{ + local($dow) = @_; + + local(@DayOfWeek) = ('So', + 'Mo', + 'Di', + 'Mi', + 'Do', + 'Fr', + 'Sa'); + + if ($dow <= 0 || $dow > 7) + { + &write_warnings("Invalid day of week number: $dow"); + } + else + { + $DayOfWeek[$dow-1]; + } +} + +sub get_short_day_of_weekname_ngerman{ + local($dow) = @_; + + local(@DayOfWeek) = ('So', + 'Mo', + 'Di', + 'Mi', + 'Do', + 'Fr', + 'Sa'); + + if ($dow <= 0 || $dow > 7) + { + &write_warnings("Invalid day of week number: $dow"); + } + else + { + $DayOfWeek[$dow-1]; + } +} + +sub get_short_day_of_weekname{ + local($dow)=@_; + local($dowsub); + + $dowsub = "get_short_day_of_weekname_$default_language"; + + if (defined ($dowsub)) + { + &$dowsub($dow); + } + else + { + substr(&get_day_of_weekname($dow),0,3); + } +} + +sub do_cmd_dayofweeknameid{ + local($_) = @_; + local($dow); + + $dow = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($dow=$2)); + + join('',&get_day_of_weekname($dow), $_); +} + +sub do_cmd_dayofweekname{ + local($_) = @_; + local($day,$month,$year); + # read 1st argument + $day = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($day=$2)); + # read 2nd argument + $month = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($month=$2)); + # read 3rd argument + $year = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($year=$2)); + + if ($day eq 'THEDAY' or $day eq '\THEDAY') + { + # this is a cludge to help newdateformat work + + join('', '{DOW}', $_); + } + else + { + local($dow) = &get_day_of_week($day,$month,$year); + + join('',&get_day_of_weekname($dow), $_); + } +} + +sub do_cmd_shortdayofweekname{ + local($_) = @_; + local($day,$month,$year); + # read 1st argument + $day = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($day=$2)); + # read 2nd argument + $month = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($month=$2)); + # read 3rd argument + $year = &missing_braces unless ((s/$next_pair_pr_rx//o)&&($year=$2)); + + local($dow) = &get_day_of_week($day,$month,$year); + + join('',&get_short_day_of_weekname($dow), $_); +} + +sub do_cmd_thisdayofweekname{ + local($dow) = &get_day_of_week($global{DAY}, $global{MONTH}, $global{YEAR}); + + join('',$DayOfWeek[$dow], $_); +} + +sub do_cmd_thisshortdayofweekname{ + local($dow) = &get_day_of_week($global{DAY}, $global{MONTH}, $global{YEAR}); + + join('',&get_short_day_of_weekname($dow), $_); +} + +$dateformat = "\\ifshowdow{DOW}\\fi {ORDINALDATE{DAY}}\\ MONTHNAME[THEMONTH], THEYEAR"; + +sub format_date{ + local($day,$month,$year) = @_; + + local($str) = $dateformat; + + $str =~ s/THEDAY/$day/g; + $str =~ s/THEMONTH/$month/g; + $str =~ s/THEYEAR/$year/g; + + $str =~ s/TWODIGIT{([\d]+)}/&get_twodigit($1)/eg; + $str =~ s/ROMANNUMERAL{([\d]+)}/&froman($1)/eg; + $str =~ s/ROMANNUMERALU{([\d]+)}/uc(&froman($1))/eg; + $str =~ s/TRUNCATE{([\d]+)}/&get_twodigit($1%100)/eg; + $str =~ s/SHORTMONTHNAME\[([\d]+)\]/&get_shortmonthname($1)/eg; + $str =~ s/MONTHNAME\[([\d]+)\]/&get_monthname($1)/eg; + + local($X) = ++$global{'max_id'}; + local($Y) = ++$global{'max_id'}; + local($Z) = ++$global{'max_id'}; + $str =~ s/{DOW}/\\dayofweekname${OP}$X${CP}$day${OP}$X${CP}${OP}$Y${CP}$month${OP}$Y${CP}${OP}$Z${CP}$year${OP}$Z${CP}/g; + $str =~ s/{SDOW}/\\shortdayofweekname${OP}$X${CP}$day${OP}$X${CP}${OP}$Y${CP}$month${OP}$Y${CP}${OP}$Z${CP}$year${OP}$Z${CP}/g; + + local($br_id) = ++$global{'max_id'}; + $suffix = &get_ordinal_suffix($day); + $str =~ s/{ORDINAL{DAY}}/$day\\fmtord${OP}$br_id${CP}$suffix${OP}$br_id${CP}/g; + + $br_id = ++$global{'max_id'}; + $suffix = &get_ordinal_suffix($month); + $str =~ s/{ORDINAL{MONTH}}/$month\\fmtord${OP}$br_id${CP}$suffix${OP}$br_id${CP}/g; + + $br_id = ++$global{'max_id'}; + $suffix = &get_ordinal_suffix($year); + $str =~ s/{ORDINAL{YEAR}}/$year\\fmtord${OP}$br_id${CP}$suffix${OP}$br_id${CP}/g; + + local($br_id) = ++$global{'max_id'}; + $str =~ s/{ORDINALDATE{DAY}}/\\ordinaldate${OP}$br_id${CP}$day${OP}$br_id${CP}/g; + + $str =~ s/{NNUMBERSTRING{DAY}}/&get_Numberstring($day)/eg; + $str =~ s/{NNUMBERSTRING{MONTH}}/&get_Numberstring($month)/eg; + $str =~ s/{NNUMBERSTRING{YEAR}}/&get_Numberstring($year)/eg; + + $str =~ s/{OORDINALSTRING{DAY}}/&get_Ordinalstring($day)/eg; + $str =~ s/{OORDINALSTRING{MONTH}}/&get_Ordinalstring($month)/eg; + $str =~ s/{OORDINALSTRING{YEAR}}/&get_Ordinalstring($year)/eg; + + $str =~ s/{CAPNUMBERSTRING{DAY}}/uc(&get_numberstring($day))/eg; + $str =~ s/{CAPNUMBERSTRING{MONTH}}/uc(&get_numberstring($month))/eg; + $str =~ s/{CAPNUMBERSTRING{YEAR}}/uc(&get_numberstring($year))/eg; + + $str =~ s/{CAPORDINALSTRING{DAY}}/uc(&get_ordinalstring($day))/eg; + $str =~ s/{CAPORDINALSTRING{MONTH}}/uc(&get_ordinalstring($month))/eg; + $str =~ s/{CAPORDINALSTRING{YEAR}}/uc(&get_ordinalstring($year))/eg; + + $str =~ s/{NUMBERSTRING{DAY}}/&get_numberstring($day)/eg; + $str =~ s/{NUMBERSTRING{MONTH}}/&get_numberstring($month)/eg; + $str =~ s/{NUMBERSTRING{YEAR}}/&get_numberstring($year)/eg; + + $str =~ s/{ORDINALSTRING{DAY}}/&get_ordinalstring($day)/eg; + $str =~ s/{ORDINALSTRING{MONTH}}/&get_ordinalstring($month)/eg; + $str =~ s/{ORDINALSTRING{YEAR}}/&get_ordinalstring($year)/eg; + + $str; +} + +sub do_cmd_formatdate{ + local($day,$month,$year); + # read 1st argument + $day = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($day=$2)); + # read 2nd argument + $month = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($month=$2)); + # read 3rd argument + $year = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($year=$2)); + + join('', &format_date($day,$month,$year), $_[0]); +} + +sub do_cmd_today{ + join('', &format_date($global{DAY},$global{MONTH},$global{YEAR}), $_[0]); +} + +sub do_cmd_day{ + join('', $global{DAY}, $_[0]); +} + +sub do_cmd_month{ + join('', $global{MONTH}, $_[0]); +} + +sub do_cmd_year{ + join('', $global{YEAR}, $_[0]); +} + +sub do_cmd_showdowtrue{ + local($_) = @_; + $showdow = 1; + $_[0]; +} + +sub do_cmd_showdowfalse{ + local($_) = @_; + $showdow = 0; + $_[0]; +} + +# This is a bit primative, it doesn't allow for +# nested conditionals + +sub do_cmd_ifshowdow{ + local($_) = @_; + local($ifbit,$elsebit); + + $_[0] =~s/(.*)\\fi//; + + $ifbit = $1; + + $ifbit =~s/(.*)\\else(.*)/\1/g; + + $elsebit = $2; + + if ($showdow) + { + join('', $ifbit, $_[0]); + } + else + { + join('', $elsebit, $_[0]); + } +} + +sub do_cmd_dateseparator{ + join('', '/', $_[0]); +} + +sub do_cmd_longdate{ + $dateformat = "\\ifshowdow{DOW}\\fi {ORDINALDATE{DAY}}\\ MONTHNAME[THEMONTH], THEYEAR"; + + $_[0]; +} + +sub do_cmd_shortdate{ + $dateformat = "\\ifshowdow{SDOW}\\fi {ORDINALDATE{DAY}}\\ SHORTMONTHNAME[THEMONTH], THEYEAR"; + + $_[0]; +} + +sub do_cmd_yyyymmdddate{ + $dateformat = "THEYEAR\\dateseparator TWODIGIT{THEMONTH}\\dateseparator TWODIGIT{THEDAY}"; + + $_[0]; +} + +sub do_cmd_ddmmyyyydate{ + $dateformat = "TWODIGIT{THEDAY}\\dateseparator TWODIGIT{THEMONTH}\\dateseparator THEYEAR"; + + $_[0]; +} + +sub do_cmd_dmyyyydate{ + $dateformat = "THEDAY\\dateseparator THEMONTH\\dateseparator THEYEAR"; + + $_[0]; +} + +sub do_cmd_dmyydate{ + $dateformat = "THEDAY\\dateseparator THEMONTH\\dateseparator TRUNCATE{THEYEAR}"; + + $_[0]; +} + +sub do_cmd_ddmmyydate{ + $dateformat = "TWODIGIT{THEDAY}\\dateseparator TWODIGIT{THEMONTH}\\dateseparator TRUNCATE{THEYEAR}"; + + $_[0]; +} + +sub do_cmd_textdate{ + $dateformat = "\\ifshowdow{DOW} the\\fi {OORDINALSTRING{DAY}} of MONTHNAME[THEMONTH], {NNUMBERSTRING{YEAR}}"; + + $_[0]; +} + +sub do_cmd_usdate{ + $dateformat = "MONTHNAME[THEMONTH] THEDAY, THEYEAR"; + + $_[0]; +} + +sub do_cmd_mmddyyyydate{ + $dateformat = "TWODIGIT{THEMONTH}\\dateseparator TWODIGIT{THEDAY}\\dateseparator THEYEAR"; + + $_[0]; +} + +sub do_cmd_mdyyyydate{ + $dateformat = "THEMONTH\\dateseparator THEDAY\\dateseparator THEYEAR"; + + $_[0]; +} + +sub do_cmd_mmddyydate{ + $dateformat = "TWODIGIT{THEMONTH}\\dateseparator TWODIGIT{THEDAY}\\dateseparator TRUNCATE{THEYEAR}"; + + $_[0]; +} + +sub do_cmd_mdyydate{ + $dateformat = "THEMONTH\\dateseparator THEDAY\\dateseparator TRUNCATE{THEYEAR}"; + + $_[0]; +} + +sub do_cmd_THEYEAR{ + join('', 'THEYEAR', $_[0]); +} + +sub do_cmd_THEMONTH{ + join('', 'THEMONTH', $_[0]); +} + +sub do_cmd_THEDAY{ + join('', 'THEDAY', $_[0]); +} + +sub do_cmd_newdateformat{ + local($_) = @_; + local($cmd,$cmdbody); + local($ntmp); + + $cmd = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($cmd=$2)); + $cmdbody = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($cmdbody=$2)); + + $ntmp = 'sub do_cmd_' . $cmd . '{'; + $ntmp .= '$dateformat = "' . $cmdbody . '";'; + + $ntmp .= '$_[0];'; + $ntmp .= '}'; + + eval($ntmp); + + join('', $_[0]); +} + +sub do_cmd_pdfdate{ + local($_) = @_; + + local($timestring) = sprintf "%d%02d%02d%02d%02d%02d", + $global{YEAR}, $global{MONTH}, $global{DAY}, $global{HOUR}, $global{MINUTE}, $global{SECONDS}; + + join('', $timestring, $_[0]); +} + + %userdates = (); + +sub do_cmd_newdate{ + local($_)=@_; + local($datename,$mon,$day,$year); + + $datename = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($datename=$2)); + + $day = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($day=$2)); + + $mon = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($mon =$2)); + + $year = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($year =$2)); + + + $userdates{$datename}{day} = $day; + $userdates{$datename}{month} = $mon; + $userdates{$datename}{year} = $year; + + join('', $_[0]); +} + +sub do_cmd_displaydate{ + local($_)=@_; + local($datename); + local($cmd,$br_id); + + $datename = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($datename=$2)); + + $br_id = ++$global{'max_id'}; + $cmd = "$OP$br_id$CP" . $userdates{$datename}{day} ."$OP$br_id$CP"; + $br_id = ++$global{'max_id'}; + $cmd .= "$OP$br_id$CP" . $userdates{$datename}{month} ."$OP$br_id$CP"; + $br_id = ++$global{'max_id'}; + $cmd .= "$OP$br_id$CP" . $userdates{$datename}{year} ."$OP$br_id$CP"; + + join('', '\formatdate', $cmd, $_[0]); +} + +sub do_cmd_getdateyear{ + local($_)=@_; + local($datename); + + $datename = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($datename=$2)); + + join('', $userdates{$datename}{year}, $_[0]); +} + +sub do_cmd_getdatemonth{ + local($_)=@_; + local($datename); + + $datename = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($datename=$2)); + + join('', $userdates{$datename}{month}, $_[0]); +} + +sub do_cmd_getdateday{ + local($_)=@_; + local($datename); + + $datename = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($datename=$2)); + + join('', $userdates{$datename}{day}, $_[0]); +} + +# time commands + +sub do_cmd_timeseparator{ + join('', ':', $_[0]); +} + +sub do_cmd_noon{ + local($_) = @_; + + join('', "Noon", $_[0]); +} + +sub do_cmd_midnight{ + local($_) = @_; + + join('', "Midnight", $_[0]); +} + +sub do_cmd_amname{ + local($_) = @_; + + join('', "am", $_[0]); +} + +sub do_cmd_pmname{ + local($_) = @_; + + join('', "pm", $_[0]); +} + +sub do_cmd_amstring{ + local($_) = @_; + + join('', "in the morning", $_[0]); +} + +sub do_cmd_pmstring{ + local($_) = @_; + + join('', "in the afternoon", $_[0]); +} + +sub do_cmd_halfpast{ + local($_) = @_; + + join('', "Half past", $_[0]); +} + +sub do_cmd_quarterpast{ + local($_) = @_; + + join('', "Quarter past", $_[0]); +} + +sub do_cmd_quarterto{ + local($_) = @_; + + join('', "Quarter to", $_[0]); +} + +sub do_cmd_oclockstring{ + local($_) = @_; + + join('', "O'Clock", $_[0]); +} + +sub do_cmd_amorpmname{ + if ($global{HOUR}>12) + { + &do_cmd_pmname; + } + else + { + &do_cmd_amname; + } +} + +sub do_cmd_amorpmstring{ + if ($global{HOUR}>12) + { + &do_cmd_pmstring; + } + else + { + &do_cmd_amstring; + } +} + +sub set_timeformat_hhmmsstime{ + $timeformat = "TWODIGIT{THEHOUR}\\timeseparator TWODIGIT{THEMINUTE}" + . "\\timeseparator TWODIGIT{THESECOND}"; +} + +sub set_timeformat_xxivtime{ + $timeformat = "TWODIGIT{THEHOUR}\\timeseparator TWODIGIT{THEMINUTE}"; +} + +sub format_ampmtime{ + local($hour,$min)=@_; + local($timestring); + local($hourxii) = ($hour == 12 ? 12 : ($hour)%12); + + $timestring = sprintf "%d\\timeseparator %02d", $hourxii, $min; + + $timestring .= ($hour < 12 ? + "\\amname " : ($hour = 12 ? " \\noon" :"\\pmname ")); + + $timestring +} + +sub do_cmd_ampmtime{ + local($_) = @_; + + join('', &format_ampm($global{HOUR},$global{MINUTE}), $_[0]); +} + +sub do_cmd_timeformat_at_ampmtime{ + local($hour,$min,$sec); + # read 1st argument + $hour = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($day=$2)); + # read 2nd argument + $min = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($month=$2)); + # read 3rd argument + $sec = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($year=$2)); + + join('', &format_ampmtime($hour, $min), $_[0]); +} + +sub do_cmd_timeformatATampmtime{&do_cmd_timeformat_at_ampmtime} + +sub set_timeformat_ampmtime{ + $timeformat = "TWODIGIT{THEHOURXII}\\timeseparator TWODIGIT{THEMINUTE}AMORPMNAME"; +} + +sub format_oclock{ + local($hour,$min)=@_; + + local($hourxii) = ($hour == 12 ? 12 : ($hour)%12); + local($tohour) = ($hour == 11 ? 12 :($hour+1)%12); + local($tominute) = ($min == 0? 0 : 60 - $min); + + local($timestring); + + if ($hour == 0 && $min == 0) + { + $timestring = "\\midnight"; + } + elsif ($hour == 12 && $min == 0) + { + $timestring = "\\noon"; + } + else + { + if ($min == 0) + { + $timestring = &get_Numberstring($hourxii) . " \\oclockstring"; + } + elsif ($min == 15) + { + $timestring = "\\quarterpast\\ " . &get_Numberstring($hourxii); + } + elsif ($min == 30) + { + $timestring = "\\halfpast\\ " . &get_Numberstring($hourxii); + } + elsif ($min == 45) + { + $timestring = "\\quarterto\\ " . &get_Numberstring($tohour); + } + elsif ($min < 30) + { + $timestring = get_Numberstring($min); + + $timestring .= ($min == 1 ? " minute" : " minutes") . " past "; + + $timestring .= get_Numberstring($hourxii); + } + else + { + $timestring = get_Numberstring($tominute); + + $timestring .= ($min == 1 ? " minute" : " minutes") . " to "; + + $timestring .= get_Numberstring($tohour); + } + + $timestring .= ($hour < 12 ? " \\amstring" : " \\pmstring"); + } + + $timestring +} + +sub do_cmd_oclock{ + local($_) = @_; + + join('', &format_oclock($global{HOUR},$global{MINUTE}), $_[0]); +} + +sub do_cmd_timeformat_at_oclock{ + local($hour,$min,$sec); + # read 1st argument + $hour = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($day=$2)); + # read 2nd argument + $min = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($month=$2)); + # read 3rd argument + $sec = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($year=$2)); + + join('', &format_oclock($hour, $min), $_[0]); +} + +sub do_cmd_timeformatAToclock{&do_cmd_timeformat_at_oclock} + +sub set_timeformat_oclock{ + $timeformat="OCLOCK"; +} + +sub do_cmd_formattime{ + local($_) = @_; + local($hour,$min,$sec); + + # read 1st argument + $hour = &missing_braces unless + (s/$next_pair_pr_rx/$hour=$2;''/eo); + # read 2nd argument + $min = &missing_braces unless + (s/$next_pair_pr_rx/$min=$2;''/eo); + # read 3rd argument + $sec = &missing_braces unless + (s/$next_pair_pr_rx/$sec=$2;''/eo); + + join('', &format_time($hour,$min,$sec), $_); +} + +sub do_cmd_currenttime{ + join('', &format_time($global{HOUR},$global{MINUTE},$global{SECONDS}), $_[0]); +} + +sub format_time{ + local($hour,$min,$sec) = @_; + + local($str) = $timeformat; + + local($hourxii) = ($hour == 12 ? 12 : ($hour)%12); + local($tohour) = ($hour == 11 ? 12 :($hour+1)%12); + local($tominute) = ($min == 0? 0 : 60 - $min); + local($amorpmname) = ($hour < 12 ? '\amname' : + ($hour == 12 ? ' \noon' : '\pmname')); + + $str =~ s/THEHOURXII/$hourxii/g; + $str =~ s/THEHOUR/$hour/g; + $str =~ s/THEMINUTE/$min/g; + $str =~ s/THESECOND/$sec/g; + $str =~ s/THETOHOUR/$tohour/g; + $str =~ s/THETOMINUTE/$tominute/g; + $str =~ s/AMORPMNAME/$amorpmname/g; + + $str =~ s/TWODIGIT{([\d]+)}/&get_twodigit($1)/eg; + $str =~ s/ROMANNUMERAL{([\d]+)}/&froman($1)/eg; + $str =~ s/ROMANNUMERALU{([\d]+)}/uc(&froman($1))/eg; + + $str =~ s/OCLOCK/&format_oclock($hour,$min)/eg; + + $str; +} + +sub do_cmd_settimeformat{ + local($_) = @_; + local($cmd); + + $cmd = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($cmd=$2)); + + eval('&set_timeformat_'.$cmd); + + $_[0]; +} + +sub do_cmd_newtimeformat{ + local($_) = @_; + local($cmd,$cmdbody); + + $cmd = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($cmd=$2)); + $cmdbody = &missing_braces unless ($_[0]=~(s/$next_pair_pr_rx//o)&&($cmdbody=$2)); + + $tmp = 'sub do_cmd_'.$cmd.'{&do_cmd_timeformat_at_'.$cmd.';}'; + eval($tmp); + + $tmp = 'sub set_timeformat_'.$cmd.'{'; + $tmp .= '$timeformat = "'.$cmdbody .'";'; + $tmp .= '}'; + eval($tmp); + + $tmp = 'sub do_cmd_timeformat_at_'.$cmd.'{'; + $tmp .= 'local($_)=@_;'; + $tmp .= 'local($hour,$min,$sec);'; + $tmp .= '$hour=&missing_braces unless '; + $tmp .= '((s/$next_pair_pr_rx//o)&&($hour=$2));'; + $tmp .= '$min=&missing_braces unless '; + $tmp .= '((s/$next_pair_pr_rx//o)&&($min=$2));'; + $tmp .= '$sec=&missing_braces unless '; + $tmp .= '((s/$next_pair_pr_rx//o)&&($sec=$2));'; + $tmp .= '&set_timeformat_'.$cmd.';'; + $tmp .= '&format_time($hour, $min, $sec).$_'; + $tmp .= "}"; + + eval($tmp); + + join('', $_[0]); +} + +sub do_cmd_THEHOUR{ + local($_) = @_; + + join('', $global{HOUR}, $_[0]); +} + +sub do_cmd_THEMINUTE{ + local($_) = @_; + + join('', $global{MINUTE}, $_[0]); +} + +sub do_cmd_THESECOND{ + local($_) = @_; + + join('', $global{SECONDS}, $_[0]); +} + +sub do_cmd_THETOHOUR{ + local($_) = @_; + + join('', $global{TOHOUR}, $_[0]); +} + +sub do_cmd_THETOMINUTE{ + local($_) = @_; + + join('', $global{TOMINUTE}, $_[0]); +} + +sub do_cmd_THEHOURXII{ + local($_) = @_; + + join('', $global{HOURXII}, $_[0]); +} + +1; |