% !TeX spellcheck = en_US
% !TeX root = tikz-ext-manual.tex
% 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.
%

\section{Calendar}
\begin{tikzlibrary}{ext.calendar-plus}
  This library extends the \tikzname\space library \referenceLibraryandIndexO{calendar}.
  \inspiration{WeekNum-Q,CalCond-Q,CalMath-Q}{WeekNum-A,CalCond-A,CalMath-A}
\end{tikzlibrary}

\begin{multicols}{2}

\subsection{Value-keys and nestable \texttt{if} key}
\begin{keylist}[/tikz]{%
  day xshift (initially 3ex),
  day yshift (initially 3.5ex),
  month xshift (initially 9ex),
  month yshift (initially 9ex)}
The values of these keys are originally stored in some macros that are not
accessible by the user. These are now simple value-keys.
The |@|-protected macros are still available, of course.
\end{keylist}

\begin{key}{/tikz/if=|(|\meta{conditions}|)|\meta{code or options}\opt{|else|\meta{else code or options}}}
  It is now also possible to nest |/tikz/if| occurrences.
\end{key}

\subsection{\pgfname math functions}
\begin{math-function}{ext\textunderscore weeksinmonthofyear(\mvar{first weekday}, \mvar{month}, \mvar{year})}
\mathcommand[extweeksinmonthofyear(\mvar{first weekday}, \mvar{month}, \mvar{year})]
  Returns the number of (partial) weeks in the month \mvar{month} of year \mvar{year}
  when this month begins on a \mvar{first weekday}.
\end{math-function}
\begin{math-function}{ext\textunderscore lastdayinmonthofyear(\mvar{month}, \mvar{year})}
\mathcommand[extlastdayinmonthofyear(\mvar{month}, \mvar{year})]
  Returns the last day (28, 29, 30 or 31) of month \mvar{month} of year \mvar{year}.
\end{math-function}

\subsection{Week numbering (ISO~8601)}

The actual week number algorithm is implemented by the |pgfcalendar-ext| package/module in section~\ref{calendar:weeknumbering}.
\begin{key}{/\tikzext/week code=\meta{code}}\keycompat{tikz}
  Works like |/tikz/day code| or |/tikz/month code|, only for weeks.\indexKeyO{day code}\indexKeyO{month code}
\end{key}

\begin{key}{/\tikzext/week text=\meta{text}}\keycompat{tikz}
  Works like |/tikz/day text| or |/tikz/month text|, only for weeks.\indexKeyO{day text}\indexKeyO{month text}
\end{key}

\begin{stylekey}{/\tikzext/every week}\keycompat{tikz}
  Works like |/tikz/every day| or |/tikz/every month|, only for weeks.\indexKeyO{every day}\indexKeyO{every month}
\end{stylekey}

\begin{stylekey}{/\tikzext/week label left}\keycompat{tikz}
    Places the week label to the left of the first day of the month. (For
    |week list| and |month list| where a week does not start on a Monday, the
    position is chosen ``as if'' the week had started on a Monday --  which is
    usually exactly what you want.)
    %
\begin{codeexample}[preamble={\usetikzlibrary{ext.calendar-plus}}]
\tikz
  \calendar[
    week list, month label above centered,
    dates=2022-07-01 to 2022-07-31,
    ext/week label left,
    ext/every week/.append style={
      gray!50!black, font=\sffamily}];
\end{codeexample}
    %
\end{stylekey}

\end{multicols}
\endinput