I did a little bit of rtfm and I've come up with some macros for that task.
First, we need to compute the 'day of the year' for a given date, i.e. the number of days that have passed since the beginning of a year with respect to a given date:
\newcount\begincnt
\def\initbegin{%
\pgfcalendardatetojulian{2014-01-01}{\begincnt}
}
\def\doy#1#2{%
\initbegin#1=#2\advance#1by-\begincnt\relax%
}
The initbegin
macro initializes the begincnt
counter to the julian day number (JDN) of the 1st of January we want to use in our calendar.
doy
gets the JDN of a 2014 date as input and sets the counter given as first argument to the day-of-the-year result.
With that we can define a weak of the year (woy) macro:
\def\woy#1#2{%
\doy{#1}{#2}\yearoff{\cnte}{#2}\advance#1by\cnte\divide#1by7\advance#1by1\relax%
}
Again, a result counter is the first argument and 2nd argument is a counter that contains the JDN of a date.
The yearoff
macro returns 2 for a 2014 date - it is needed as 'correction' for years where the first of January is not a Monday. Its code:
\newcount\cntd
\newcount\cnte
\def\myyear{}
\def\mydummy{}
\def\yearoff#1#2{%
\pgfcalendarjuliantodate{#2}{\myyear}{\mydummy}{\mydummy}%
\pgfcalendardatetojulian{\myyear-01-01}{\cntd}%
\pgfcalendarjuliantoweekday{\cntd}{#1}\relax%
}
With that we are (nearly) ready to define a custom pgf-key for ifdate-clauses in PGF- and TikZ-Calendar constructs:
\newcount\cnta
\newcount\cntb
\newcount\cntp
\pgfkeys{/pgf/calendar/modb/.cd,.value required,.code={
\woy{\cnta}{\pgfcalendarifdatejulian}\mod{\cntb}{\cnta}{\cntp}
\ifnum\cntb=#1\relax%
\pgfcalendarmatchestrue%
\fi%
}}
This filter uses another custom macro mod
to compute the modulo (\cntp
contains the number of parties):
\def\mod#1#2#3{%
#1=#2\relax%
\divide#1by#3\relax%
\multiply#1by-#3\relax%
\advance#1by#2\relax%
}
Examples
We can use the filter like this:
On 2014-01-06 the 2nd party is \pgfcalendarifdate{2014-01-06}{modb=1}{not} in charge.
Or in a TikZ-calendar command:
\tikz
\calendar[dates=2014-01-01 to 2014-03-last, week list,month label above centered]
if (modb=2) [nodes={fill=blue!60}]
;
(which colorizes all days where the third party is in charge)
Or as part of a calendar style:
\begin{tikzpicture}[every calendar/.style={
if={(modb=0) [nodes={fill=yellow!60}]}
}