| 1 |
% !TeX spellcheck = en_US |
| 2 |
% !TeX root = tikz-ext-manual.tex |
| 3 |
% Copyright 2022 by Qrrbrbirlbel |
| 4 |
% |
| 5 |
% This file may be distributed and/or modified |
| 6 |
% |
| 7 |
% 1. under the LaTeX Project Public License and/or |
| 8 |
% 2. under the GNU Free Documentation License. |
| 9 |
% |
| 10 |
|
| 11 |
\section{Calendar: Weeknumbers and more conditionals} |
| 12 |
\label{sec:calendar} |
| 13 |
\begin{texpackage}{pgfcalendar-ext} |
| 14 |
This package adds week numbers and more conditionals to the \pgfname\space package |pgfcalendar|. |
| 15 |
% (Despite the code example above, this package is not set up to work with Con\TeX t.) |
| 16 |
\inspiration{WeekNum-Q,CalCond-Q,CalFullWeek-Q}{WeekNum-A,CalCond-A,CalFullWeek-A} |
| 17 |
\end{texpackage} |
| 18 |
|
| 19 |
%This package extends the |pgfcalendar| package. |
| 20 |
|
| 21 |
\begin{multicols}{2} |
| 22 |
|
| 23 |
\subsection{Extensions} |
| 24 |
|
| 25 |
The following tests are added. |
| 26 |
In version pre~0.6, they're missing the prefix |ext/|. |
| 27 |
\begin{itemize} |
| 28 |
\itemcalendaroption{ext/Jan} This test is passed by all dates that are in the month of January. |
| 29 |
\itemcalendaroption{ext/Feb} as above. |
| 30 |
\itemcalendaroption{ext/Mar} as above. |
| 31 |
\itemcalendaroption{ext/Apr} as above. |
| 32 |
\itemcalendaroption{ext/May} as above. |
| 33 |
\itemcalendaroption{ext/Jun} as above. |
| 34 |
\itemcalendaroption{ext/Jul} as above. |
| 35 |
\itemcalendaroption{ext/Aug} as above. |
| 36 |
\itemcalendaroption{ext/Sep} as above. |
| 37 |
\itemcalendaroption{ext/Oct} as above. |
| 38 |
\itemcalendaroption{ext/Nov} as above. |
| 39 |
\itemcalendaroption{ext/Dec} as above. |
| 40 |
\itemcalendaroption{ext/leap year}\opt{|=|\meta{year}} |
| 41 |
This test checks whether the given year is a leap year. If |
| 42 |
\meta{year} is omitted, it checks the year of the current date. |
| 43 |
\itemcalendaroption{ext/and}|=|\marg{tests} |
| 44 |
This test passes when all \meta{tests} pass. |
| 45 |
\itemcalendaroption{ext/not}|=|\marg{tests} |
| 46 |
This test passes when \meta{tests} do not pass. |
| 47 |
\itemcalendaroption{ext/week of month}|=|\meta{num} |
| 48 |
This test passes when the date is in \meta{num}th week of the month. |
| 49 |
The first week of the month start at day~1 and ends with day~7. |
| 50 |
\itemcalendaroption{ext/week of month'}|=|\meta{num} |
| 51 |
As above but counts from the last day of the month. |
| 52 |
For a month with 31~days, this means the ``1st'' week starts at day~25 and ends with day~31. |
| 53 |
\itemcalendaroption{ext/calendar week of month}|=|\meta{num} |
| 54 |
This test passes when the date is in \meta{num}th calendar week of the month. |
| 55 |
The first week starts at the first day of the month and ends at the next Sunday. |
| 56 |
\itemcalendaroption{ext/calendar week of month'}|=|\meta{num} |
| 57 |
As above but counts from the last day of the month. |
| 58 |
\begin{codeexample}[width=5cm,preamble=\usetikzlibrary{ext.calendar-plus}] |
| 59 |
\tikz |
| 60 |
\calendar[ |
| 61 |
dates=2022-10-01 to 2022-10-31, |
| 62 |
week list] |
| 63 |
if (ext/week of month=2) [red] |
| 64 |
if (ext/calendar week of month'=2) [blue]; |
| 65 |
\end{codeexample} |
| 66 |
\itemcalendaroption{ext/yesterday}|=|\marg{tests} |
| 67 |
This test passes when the previous day passes \meta{tests}. |
| 68 |
\itemcalendaroption{ext/week}|=|\meta{num} |
| 69 |
This test passes when the current week of the year equals \meta{num}. |
| 70 |
\end{itemize} |
| 71 |
The shorthands for |d-| and |m-| are slightly changed so that they are |
| 72 |
expandable. This makes it possible to use these shorthands inside of \pgfname math. |
| 73 |
The shorthands for the week (see section~\ref{calendar:weeknumbering}) |
| 74 |
are added. These are |
| 75 |
\begin{itemize} |
| 76 |
\item |n-| (shortest numerical representation), |
| 77 |
\item |n=| (shortest but added horizontal space) and |
| 78 |
\item |n0| (leading zero when below 10). |
| 79 |
\end{itemize} |
| 80 |
|
| 81 |
\subsection{Week numbering (ISO~8601)} |
| 82 |
\label{calendar:weeknumbering} |
| 83 |
\begin{command}{\pgfextcalendarjulianyeartoweek\marg{Julian day}\marg{year}\marg{week count}} |
| 84 |
\cmdcompat{\pgfcalendarjulianyeartoweek} |
| 85 |
This command calculates the week for the \meta{Julian day} of \meta{year}. |
| 86 |
The \meta{week counter} must be a \TeX\space count. |
| 87 |
|
| 88 |
The calculation follows the rule of ISO~8601 where the first week has that |
| 89 |
year's first Thursday in it. |
| 90 |
\end{command} |
| 91 |
|
| 92 |
Inside of |\pgfcalendar|\indexCommandO\pgfcalendar the command |\pgfextcalendarcurrentweek| will be available. |
| 93 |
\begin{command}{\pgfextcalendarcurrentweek} |
| 94 |
\cmdcompat{\pgfcalendarcurrentweek} |
| 95 |
This command returns the current week number (always two digits -- use shorthand |n.| |
| 96 |
to strip the leading zero). |
| 97 |
\end{command} |
| 98 |
|
| 99 |
Inside of |\ifdate|\indexCommandO\ifdate the command |\pgfextcalendarifdateweek| will be available. |
| 100 |
\begin{command}{\pgfextcalendarifdateweek} |
| 101 |
\cmdcompat{\pgfcalendarifdateweek} |
| 102 |
This command returns the week number (always two digits). |
| 103 |
\end{command} |
| 104 |
\end{multicols} |