diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/datetime2/datetime2-calc.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/datetime2/datetime2-calc.sty | 228 |
1 files changed, 228 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/datetime2/datetime2-calc.sty b/Master/texmf-dist/tex/latex/datetime2/datetime2-calc.sty new file mode 100644 index 00000000000..006b1c4671d --- /dev/null +++ b/Master/texmf-dist/tex/latex/datetime2/datetime2-calc.sty @@ -0,0 +1,228 @@ +%% +%% This is file `datetime2-calc.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% datetime2.dtx (with options: `datetime2-calc.sty,package') +%% +%% datetime2.dtx +%% Copyright 2015 Nicola 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. +%% +%% This work consists of the files datetime2.dtx and datetime2.ins and the derived files datetime2.sty, datetime2-calc.sty. +%% +%% \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 \~} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{datetime2-calc}[2015/03/24 v1.0 (NLCT)] +\RequirePackage{pgfkeys} +\RequirePackage{pgfcalendar} +\newcount\@dtm@julianday +\def\@dtm@parsedate#1-#2-#3\@dtm@endparsedate{% + \pgfcalendardatetojulian{#1-#2-#3}{\@dtm@julianday}% + \pgfcalendarjuliantodate{\@dtm@julianday}{\@dtm@year}{\@dtm@month}{\@dtm@day}% + \pgfcalendarjuliantoweekday{\@dtm@julianday}{\count@}% + \edef\@dtm@dow{\number\count@}% +} +\pgfcalendardatetojulian + {\@dtm@currentyear-\@dtm@currentmonth-\@dtm@currentday}% + {\@dtm@julianday}% +\pgfcalendarjuliantoweekday{\@dtm@julianday}{\count@}% +\edef\@dtm@currentdow{\number\count@}% +\newrobustcmd*{\DTMsavejulianday}[2]{% + \pgfcalendarjuliantodate{#2}{\@dtm@year}{\@dtm@month}{\@dtm@day}% + \pgfcalendarjuliantoweekday{#2}{\count@}% + \csedef{@dtm@#1@dow}{\number\count@}% + \cslet{@dtm@#1@year}{\@dtm@year}% + \cslet{@dtm@#1@month}{\@dtm@month}% + \cslet{@dtm@#1@day}{\@dtm@day}% + \ifcsundef{@dtm@#1@hour}{\csdef{@dtm@#1@hour}{0}}{}% + \ifcsundef{@dtm@#1@minute}{\csdef{@dtm@#1@minute}{0}}{}% + \ifcsundef{@dtm@#1@second}{\csdef{@dtm@#1@second}{0}}{}% + \ifcsundef{@dtm@#1@TZhour}{\csdef{@dtm@#1@TZhour}{0}}{}% + \ifcsundef{@dtm@#1@TZminute}{\csdef{@dtm@#1@TZminute}{0}}{}% +} +\newrobustcmd*{\DTMsaveddatetojulianday}[2]{% + \ifcsundef{@dtm@#1@year}% + {% + \PackageError{datetime2-calc}{Unknown date `#1'}{}% + }% + {% + \pgfcalendardatetojulian + {\csname @dtm@#1@year\endcsname + -\csname @dtm@#1@month\endcsname + -\csname @dtm@#1@day\endcsname} + {#2}% + }% +} +\newrobustcmd*{\DTMsaveddateoffsettojulianday}[3]{% + \ifcsundef{@dtm@#1@year}% + {% + \PackageError{datetime2-calc}{Unknown date `#1'}{}% + }% + {% + \pgfcalendardatetojulian + {\csname @dtm@#1@year\endcsname + -\csname @dtm@#1@month\endcsname + -\csname @dtm@#1@day\endcsname + +#2} + {#3}% + }% +} +\newrobustcmd*{\DTMifdate}[4]{% + \ifcsundef{@dtm@#1@year}% + {% + \PackageError{datetime2-calc}{Unknown date `#1'}{}% + }% + {% + \pgfcalendarifdate + {\csname @dtm@#1@year\endcsname + -\csname @dtm@#1@month\endcsname + -\csname @dtm@#1@day\endcsname} + {#2}{#3}{#4}% + }% +} +\newrobustcmd*{\DTMsaveddatediff}[3]{% + \ifcsundef{@dtm@#1@year}% + {% + \PackageError{datetime2-calc}{Unknown date `#1'}{}% + }% + {% + \ifcsundef{@dtm@#2@year}% + {% + \PackageError{datetime2-calc}{Unknown date `#1'}{}% + }% + {% + \pgfcalendardatetojulian + {\csname @dtm@#1@year\endcsname + -\csname @dtm@#1@month\endcsname + -\csname @dtm@#1@day\endcsname} + {#3}% + \pgfcalendardatetojulian + {\csname @dtm@#2@year\endcsname + -\csname @dtm@#2@month\endcsname + -\csname @dtm@#2@day\endcsname} + {\@dtm@julianday}% + \advance#3 by -\@dtm@julianday\relax + } + }% +} +\newrobustcmd*{\DTMtozulu}[2]{% + \ifcsundef{@dtm@#1@year}% + {% + \PackageError{datetime2-calc}{Unknown date `#1'}{}% + }% + {% + \DTMsaveaszulutime{#2}% + {\DTMfetchyear{#1}}% + {\DTMfetchmonth{#1}}% + {\DTMfetchday{#1}}% + {\DTMfetchhour{#1}}% + {\DTMfetchminute{#1}}% + {\DTMfetchsecond{#1}}% + {\DTMfetchTZhour{#1}}% + {\DTMfetchTZminute{#1}}% + }% +} +\newrobustcmd*{\DTMsaveaszulutime}[9]{% + \edef\@dtm@year{\number#2}% + \edef\@dtm@month{\number#3}% + \edef\@dtm@day{\number#4}% + \edef\@dtm@hour{\number#5}% + \edef\@dtm@minute{\number#6}% + \edef\@dtm@second{\number#7}% + \edef\@dtm@TZhour{\number#8}% + \edef\@dtm@TZminute{\number#9}% + \pgfcalendardatetojulian{\@dtm@year-\@dtm@month-\@dtm@day}{\@dtm@julianday}% + \ifnum\@dtm@TZminute=0\relax + \else + \count@=\@dtm@minute\relax + \ifnum\@dtm@TZhour<0\relax + \advance\count@ by -\@dtm@TZminute\relax + \else + \advance\count@ by \@dtm@TZminute\relax + \fi + \edef\@dtm@minute{\number\count@}% + \ifnum\count@<0\relax + \advance\count@ by 60\relax + \edef\@dtm@minute{\number\count@}% + \ifnum\@dtm@hour=0\relax + \def\@dtm@hour{23}% + \advance\@dtm@julianday by -1\relax + \else + \count@ = \@dtm@hour\relax + \advance\count@ by -1\relax + \edef\@dtm@hour{\number\count@}% + \fi + \else + \ifnum\count@>59\relax + \advance\count@ by -60\relax + \edef\@dtm@minute{\number\count@}% + \count@ = \@dtm@hour\relax + \advance\count@ by 1\relax + \edef\@dtm@hour{\number\count@}% + \ifnum\thehour=24\relax + \def\thehour{00}% + \advance\@dtm@julianday by 1\relax + \fi + \fi + \fi + \fi + \ifnum\@dtm@TZhour=0\relax + \else + \count@=\@dtm@hour\relax + \advance\count@ by \@dtm@TZhour\relax + \ifnum\count@<0\relax + \advance\count@ by 24\relax + \edef\@dtm@hour{\number\count@}% + \advance\@dtm@julianday by -1\relax + \else + \ifnum\count@>23\relax + \advance\count@ by -24\relax + \edef\@dtm@hour{\number\count@}% + \advance\@dtm@julianday by 1\relax + \else + \edef\@dtm@hour{\number\count@}% + \fi + \fi + \fi + \pgfcalendarjuliantodate{\@dtm@julianday}{\@dtm@year}{\@dtm@month}{\@dtm@day}% + \pgfcalendarjuliantoweekday{\@dtm@julianday}{\count@}% + \csedef{@dtm@#1@dow}{\number\count@}% + \cslet{@dtm@#1@year}{\@dtm@year}% + \cslet{@dtm@#1@month}{\@dtm@month}% + \cslet{@dtm@#1@day}{\@dtm@day}% + \cslet{@dtm@#1@hour}{\@dtm@hour}% + \cslet{@dtm@#1@minute}{\@dtm@minute}% + \cslet{@dtm@#1@second}{\@dtm@second}% + \csdef{@dtm@#1@TZhour}{0}% + \csdef{@dtm@#1@TZminute}{0}% +} +\endinput +%% +%% End of file `datetime2-calc.sty'. |