blob: 195ecf9414e3decd098610e96a9f89763ce755ae (
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
|
% 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{%
\pgfutil@addto@macro\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\pgfutil@addto@macro\pgfutil@secondoftwo
\tikz@lib@cal@ifs%
\tikzdaycode%
\tikz@atend@day%
\endscope%
\tikz@after@day%
}%
\endgroup%
}
\def\pgfutil@addto@macro#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
}
|