diff options
author | Karl Berry <karl@freefriends.org> | 2012-09-18 23:42:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-09-18 23:42:21 +0000 |
commit | 7d3fe67946edf779c9af7cf56549b46e86255fe1 (patch) | |
tree | ea7d01bb0b6f8dc5825f4c2025a0bd5a5b5b4215 /Master/texmf-dist/tex/latex | |
parent | e5b88ab6891e9bb2dc1ac846e942f5bf4e21dfe0 (diff) |
new latex package calcage (18sep12)
git-svn-id: svn://tug.org/texlive/trunk@27725 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/calcage/calcage.sty | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/calcage/calcage.sty b/Master/texmf-dist/tex/latex/calcage/calcage.sty new file mode 100644 index 00000000000..61c7fc4ea74 --- /dev/null +++ b/Master/texmf-dist/tex/latex/calcage/calcage.sty @@ -0,0 +1,80 @@ +%% See file 'calcage.dtx' for copyright and licence. +\NeedsTeXFormat{LaTeX2e}[1998/12/01] +\ProvidesPackage{calcage} + [2012/09/09 v0.90 Calculate the age in years] +\RequirePackage{fnumprint}[2012/08/27] +\RequirePackage{ + datenumber, + fp, + calc, + xkeyval, + kvoptions, + xifthen, +} +\DeclareStringOption{year} +\DeclareStringOption{month} +\DeclareStringOption{day} +\DeclareStringOption{precision}[3] +\DeclareBoolOption{positive} +\DeclareBoolOption{printyear} +\DeclareBoolOption{yearsuffix} +\DeclareBoolOption{numberstring} +\ProcessLocalKeyvalOptions* +\edef\calcage@options{\@ptionlist{\@currname.\@currext}} +%% ^^A \renewcommand{\calcage@options}{precision=4,printyear=false} +%% ^^A Package xkeyval Error: `precision=4' undefined in families `calcage'. +\ifcase\value{fnumprint@language}\or + \newcommand{\calcage@yearWord}{Jahr} + \newcommand{\calcage@yearPluralSuffix}{e} + \newcommand{\calcage@yearSuffix}{n} +\or + \newcommand{\calcage@yearWord}{year} + \newcommand{\calcage@yearPluralSuffix}{s} + \newcommand{\calcage@yearSuffix}{} +\fi +\newcounter{calcage@today}\newcounter{calcage@ageindays} +\newcounter{calcage@myyear}\newcounter{calcage@leapyears} +\newcommand{\calcage}[4][]{% + \setkeys{calcage}{precision=0, positive=true, printyear=true, + yearsuffix=false, numberstring=true, + year=\the\year, month=\the\month, day=\the\day, \calcage@options, #1}% + \setmydatenumber{calcage@today}{\calcage@year}{\calcage@month}{\calcage@day}% + \setmydatenumber{calcage@ageindays}{#2}{#3}{#4}% + \setcounter{calcage@myyear}{#2}% + \setcounter{calcage@leapyears}{0}% + \ifthenelse{\equal{#2}{\calcage@year}}{}{% + \ifthenelse{\value{calcage@myyear}<\calcage@year}{% + \loop% + \stepcounter{calcage@myyear}% + \ifleapyear{\thecalcage@myyear}\stepcounter{calcage@leapyears}\fi% + \ifnum\value{calcage@myyear}<\calcage@year% + \repeat% + }{% + \loop% + \ifleapyear{\thecalcage@myyear}\addtocounter{calcage@leapyears}{-1}\fi% + \addtocounter{calcage@myyear}{-1}% + \ifnum\value{calcage@myyear}>\calcage@year% + \repeat% + }% + }% + \setcounter{calcage@ageindays}{\value{calcage@today} + - \value{calcage@ageindays} - \value{calcage@leapyears}}% + \ifthenelse{\boolean{calcage@positive} \AND \value{calcage@ageindays} < 0}{% + \setcounter{calcage@ageindays}{\value{calcage@ageindays} * -1}% + }{}% + \FPdiv\calcage@age{\thecalcage@ageindays}{365}% + \FPtrunc\calcage@age{\calcage@age}{\calcage@precision}% + \ifthenelse{\boolean{calcage@numberstring} + \AND \equal{\calcage@precision}{0}}% + {\fnumprint[ein]{\calcage@age}}{\numprint{\calcage@age}}% + \ifthenelse{\boolean{calcage@printyear}}{% + ~\calcage@yearWord% + \ifthenelse{\equal{\calcage@age}{1} \OR \equal{\calcage@age}{-1}}{}{% + \calcage@yearPluralSuffix% + \ifthenelse{\boolean{calcage@yearsuffix}}{\calcage@yearSuffix}{}% + }% + }{}% +} +\endinput +%% +%% End of file `calcage.sty'. |