summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tikz-ext/tikz-ext-manual-en-calendar.tex
blob: 09bd261a2176a9e42207cb89bc3aae603e1d41ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
% !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: Weeknumbers and more conditionals}
\label{sec:calendar}
\begin{package}{calendar-ext}
  This package adds week numbers and more conditionals to the \pgfname\space package |pgfcalendar|.
  (Despite the code example above, this package is not set up to work with Con\TeX t.)
  \inspiration{WeekNum-Q,CalCond-Q,CalFullWeek-Q}{WeekNum-A,CalCond-A,CalFullWeek-A}
\end{package}

%This package extends the |pgfcalendar| package.

\begin{multicols}{2}

\subsection{Extensions}

The following tests are added.
\begin{itemize}
\itemcalendaroption{Jan} This test is passed by all dates that are in the month of January.
\itemcalendaroption{Feb} as above.
\itemcalendaroption{Mar} as above.
\itemcalendaroption{Apr} as above.
\itemcalendaroption{May} as above.
\itemcalendaroption{Jun} as above.
\itemcalendaroption{Jul} as above.
\itemcalendaroption{Aug} as above.
\itemcalendaroption{Sep} as above.
\itemcalendaroption{Oct} as above.
\itemcalendaroption{Nov} as above.
\itemcalendaroption{Dec} as above.
\itemcalendaroption{leap year}\opt{|=|\meta{year}}
    This test checks whether the given year is a leap year. If
    \meta{year} is omitted, it checks the year of the current date.
\itemcalendaroption{and}|=|\marg{tests}
    This test passes when all \meta{tests} pass.
\itemcalendaroption{not}|=|\marg{tests}
    This test passes when \meta{tests} do not pass.
\itemcalendaroption{week of month}|=|\meta{num}
    This test passes when the date is in \meta{num}th week of the month.
    The first week of the month start at day~1 and ends with day~7.
\itemcalendaroption{week of month'}|=|\meta{num}
    As above but counts from the last day of the month.
    For a month with 31~days, this means the ``1st'' week starts at day~25 and ends with day~31.
\itemcalendaroption{calendar week of month}|=|\meta{num}
    This test passes when the date is in \meta{num}th calendar week of the month.
    The first week starts at the first day of the month and ends at the next Sunday.
\itemcalendaroption{calendar week of month'}|=|\meta{num}
    As above but counts from the last day of the month.
\begin{codeexample}[width=5cm,preamble=\usetikzlibrary{ext.calendar-plus}]
\tikz
  \calendar[
    dates=2022-10-01 to 2022-10-31,
    week list]
    if (week of month=2) [red]
    if (calendar week of month'=2) [blue];
\end{codeexample}
\itemcalendaroption{yesterday}|=|\marg{tests}
    This test passes when the previous day passes \meta{tests}.
\itemcalendaroption{week}|=|\meta{num}
    This test passes when the current week of the year equals \marg{num}.
\end{itemize}
The shorthands for |d-| and |m-| are slightly changed so that they are
expandable. This makes it possible to use these shorthands inside of \pgfname math.
The shorthands for the week (see section~\ref{calendar:weeknumbering})
are added. These are
\begin{itemize}
\item |n-| (shortest numerical representation),
\item |n=| (shortest but added horizontal space) and
\item |n0| (leading zero when below 10).
\end{itemize}

\subsection{Week numbering (ISO~8601)}
\label{calendar:weeknumbering}
\begin{command}{\pgfcalendarjulianyeartoweek\marg{Julian day}\marg{year}\marg{week counter}}
  This command calculates the week for the \meta{Julian day} of \meta{year}.
  The \meta{week counter} must be a \TeX\space counter.

  The calculation follows the rule of ISO~8601 where the first week has that
  year's first Thursday in it.
\end{command}

Inside of |\pgfcalendar|\indexCommandO\pgfcalendar the command |\pgfcalendarcurrentweek| will be available.
\begin{command}{\pgfcalendarcurrentweek}
  This command returns the current week number (always two digits -- use shorthand |n.|
  to strip the leading zero).
\end{command}

Inside of |\ifdate|\indexCommandO\ifdate the command |\pgfcalendarifdateweek| will be available.
\begin{command}{\pgfcalendarifdateweek}
  This command returns the week number (always two digits).
\end{command}
\end{multicols}