summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-ext/tikzlibraryext.calendar-plus.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/tikz-ext/tikzlibraryext.calendar-plus.code.tex')
-rw-r--r--graphics/pgf/contrib/tikz-ext/tikzlibraryext.calendar-plus.code.tex93
1 files changed, 93 insertions, 0 deletions
diff --git a/graphics/pgf/contrib/tikz-ext/tikzlibraryext.calendar-plus.code.tex b/graphics/pgf/contrib/tikz-ext/tikzlibraryext.calendar-plus.code.tex
new file mode 100644
index 0000000000..d1300ed290
--- /dev/null
+++ b/graphics/pgf/contrib/tikz-ext/tikzlibraryext.calendar-plus.code.tex
@@ -0,0 +1,93 @@
+% Copyright 2022 by Qrrbrbirlbel
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Free Documentation License.
+%
+
+\usetikzlibrary{calendar}
+\pgfutil@usemodule{pgfcalendar-ext}
+
+% Shift between days
+
+\def\tikz@lib@cal@xshift{\pgfkeysvalueof{/tikz/day xshift}}
+\def\tikz@lib@cal@yshift{\pgfkeysvalueof{/tikz/day yshift}}
+\tikzset{day xshift/.initial=3ex,day yshift/.initial=3.5ex}
+
+% Shift between months
+
+\def\tikz@lib@cal@month@xshift{\pgfkeysvalueof{/tikz/month xshift}}
+\def\tikz@lib@cal@month@yshift{\pgfkeysvalueof{/tikz/month yshift}}
+\tikzset{month xshift/.initial=9ex,month yshift/.initial=9ex}
+
+% Internal option for storing the "width" of a calendar as a number of
+% days
+
+\def\tikz@lib@cal@width{\pgfkeysvalueof{/tikz/tikz@lib@cal@width}}
+\tikzset{tikz@lib@cal@width/.initial=1}
+
+% Weeks
+
+\def\tikzweekcode{\pgfkeysvalueof{/tikz/week code}}
+\def\tikzweektext{\pgfkeysvalueof{/tikz/week text}}
+
+\tikzset{
+ week code/.initial={%
+ \node[every week]{\pgfkeysvalueof{/tikz/week text}};},
+ week text/.initial={\%n=},
+ every week/.style=,
+ week label left/.style={
+ every week/.append style={
+ anchor=base east,
+ xshift=-1.25*\pgfkeysvalueof{/tikz/day xshift}},
+ execute before day scope=%
+ \ifdate{Monday, equals=\pgfcalendarbeginiso}{\tikzweekcode}{}}}
+
+%
+% Overwriting original \tikz@lib@cal@if@else@code
+%
+\def\tikz@lib@cal@if@else@code#1#2#3{%
+ \tikzcalendar@addto\tikz@lib@cal@ifs{\ifdate{#1}{#2}{#3}}%
+ \tikz@lib@cal@scanner%
+}
+
+%
+% Overwriting original \tikz@lib@cal@stop
+%
+\def\tikz@lib@cal@stop{%
+ \pgftransformshift{\tikz@node@at}%
+ \expandafter\pgfcalendar\expandafter{\tikz@fig@name}{\tikz@lib@cal@start}{\tikz@lib@cal@end}%
+ {%
+ \tikz@before@day%
+ \scope%
+ \tikz@atbegin@day%
+ \let\tikzcalendar@addto\pgfutil@secondoftwo
+ \tikz@lib@cal@ifs%
+ \tikzdaycode%
+ \tikz@atend@day%
+ \endscope%
+ \tikz@after@day%
+ }%
+ \endgroup%
+}
+
+\def\tikzcalendar@addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
+
+\pgfmathdeclarefunction{weeksinmonthofyear}{3}{% #1 = first weekday, #2 = month, #3 = year
+ \begingroup
+ \pgfmathlastdayinmonthofyear@{#2}{#3}%
+ \pgfmathadd@{#1}{\pgfmathresult}%
+ \pgfmathdivide@{\pgfmathresult}{7}%
+ \pgfmathceil@{\pgfmathresult}%
+ \pgfmathint@{\pgfmathresult}%
+ \pgfmathsmuggle\pgfmathresult
+ \endgroup
+}
+\pgfmathdeclarefunction{lastdayinmonthofyear}{2}{% #1 = month, #2 = year
+ \begingroup
+ \pgfcalendar@getlastYMX{#2}{#1}{\pgfutil@tempcnta}%
+ \edef\pgfmathresult{\the\pgfutil@tempcnta}%
+ \pgfmathsmuggle\pgfmathresult
+ \endgroup
+} \ No newline at end of file