\def\CalendrierFP@version{Version 0.46, 9 mai 2003}
\message{`Calendrier avec FP', \CalendrierFP@version\space Manuel Luque}
% Requires PSTricks, pstcol, pst-3d, multido, fp packages
\RequirePackage{pstricks}
\RequirePackage{pst-3d}
\RequirePackage{multido}
\RequirePackage{fp}
\FPmessagesfalse
\RequirePackage{pst-key}
%% Manuel LUQUE <Mluque5130aol.com> %%
%% 1 Octobre 1999 pour le dodécaèdre %%
%% 23 avril 2003 pour le calendrier %%
%% 27 avril : placer une date de son choix
%% suggestion de Jean-Michel Sarlat
%% jours fériés et fêtes : 1 mai 003 %%
%% 1 et 8 mai, 15 août, 1 et 11 novembre, 25 décembre
%% fête de Pâques %%
%% ascension et pentecôte : 8 mai 2003

\definecolor{RougeA}{cmyk}{0.05,0.1,0.1,0}
\definecolor{RougeB}{cmyk}{0.05,0.15,0.15,0}
\definecolor{RougeC}{cmyk}{0.05,0.2,0.2,0}
\definecolor{RougeD}{cmyk}{0.05,0.25,0.25,0}
\definecolor{RougeE}{cmyk}{0.05,0.3,0.3,0}
\definecolor{RougeF}{cmyk}{0.05,0.35,0.35,0}
\definecolor{RougeG}{cmyk}{0.05,0.4,0.4,0}
\definecolor{RougeH}{cmyk}{0.05,0.45,0.45,0}
\definecolor{RougeI}{cmyk}{0.05,0.5,0.5,0}
\definecolor{RougeJ}{cmyk}{0.05,0.55,0.55,0}
\definecolor{RougeK}{cmyk}{0.05,0.6,0.6,0}
\definecolor{RougeL}{cmyk}{0.1,0.65,0.65,0}
\newpsstyle{holiday}{framesep=2pt,doubleline=true,doublecolor=red,linecolor=red,fillstyle=solid,fillcolor=RougeA}
\SpecialCoor%
\define@key{psset}{Vx}{\edef\psk@Solide@Viewpointx{#1}}
\define@key{psset}{Vy}{\edef\psk@Solide@Viewpointy{#1}}
\define@key{psset}{Vz}{\edef\psk@Solide@Viewpointz{#1}}
\setkeys{psset}{Vx=1,Vy=1,Vz=1}
\def\RA{7.36022}\gdef\rb{5.06525}\gdef\ra{8.19574}%
\gdef\rc{5.06525}\gdef\rd{8.19574}
\newpsstyle{janvier}{Vx=-\rc,Vy=0,Vz=-\rd,viewangle=108}
\newpsstyle{fevrier}{Vx=\rc,Vy=0,Vz=-\rd,viewangle=180}
\newpsstyle{mars}{Vx=0,Vy=-\ra,Vz=-\rb,viewangle=144}
\newpsstyle{avril}{Vx=-\rd,Vy=-\rc,Vz=0,viewangle=162}
\newpsstyle{mai}{Vx=-\rd,Vy=\rc,Vz=0,viewangle=198}
\newpsstyle{juin}{Vx=0,Vy=\ra,Vz=-\rb,viewangle=216}
\newpsstyle{juillet}{Vx=-\rc,Vy=0,Vz=\rd,viewangle=0}
\newpsstyle{aout}{Vx=0,Vy=-\ra,Vz=\rb,viewangle=-36}
\newpsstyle{septembre}{Vx=\rd,Vy=-\rc,Vz=0,viewangle=-18}
\newpsstyle{octobre}{Vx=\rd,Vy=\rc,Vz=0,viewangle=18}
\newpsstyle{novembre}{Vx=0,Vy=\ra,Vz=\rb,viewangle=36}
\newpsstyle{decembre}{Vx=\rc,Vy=0,Vz=\rb,viewangle=0}
%
\def\dodecaedre{%
\@ifnextchar[{\pst@dodecaedre}{\pst@dodecaedre[]}}%
\def\pst@dodecaedre[#1]{{%
\setkeys{psset}{#1}%
\pspicture(-8,-12)(8,12)%
\psset{fillstyle=solid}%
\psset{viewpoint={\psk@Solide@Viewpointx} {\psk@Solide@Viewpointy} {\psk@Solide@Viewpointz}}%
\newcommand{\faceA}{\pspolygon(\RA;18)(\RA;90)(\RA;162)(\RA;234)(\RA;306)}
\newcommand{\faceB}{\pspolygon(\RA;270)(\RA;-18)(\RA;54)(\RA;126)(\RA;198)}
\newcommand{\faceC}{\pspolygon(\RA;0)(\RA;72)(\RA;144)(\RA;216)(\RA;288)}
\newcommand{\faceD}{\pspolygon(\RA;36)(\RA;108)(\RA;180)(\RA;252)(\RA;324)}
%face1
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(0)+(\psk@Solide@Viewpointy)*(\ra)+(\psk@Solide@Viewpointz)*(\rb)}%
\FPifpos{\Test}\ThreeDput[normal=0 {\ra} {\rb}](0,\ra,\rb){%
\psset{fillcolor=RougeA}\faceA\rput{36}{\rput(-1.8,0){\Calendrier[Mois=11]}}}\fi
%face2
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(0)-(\psk@Solide@Viewpointy)*(\ra)+(\psk@Solide@Viewpointz)*(\rb)}%
\FPifpos{\Test}\ThreeDput[normal=0 {-\ra} {\rb}](0,-\ra,\rb){%
\psset{fillcolor=RougeB}\faceA\rput{-36}{\rput(-1.8,0){\Calendrier[Mois=8]}}}\fi
%face3
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(0)+(\psk@Solide@Viewpointy)*(\ra)-(\psk@Solide@Viewpointz)*(\rb)}%
\FPifpos{\Test}\ThreeDput[normal=0 {\ra} {-\rb}](0,\ra,-\rb){%
\psset{fillcolor=RougeC}\faceB\rput{216}{\rput(-1.8,0){\Calendrier[Mois=6]}}}\fi
%face4
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(0)-(\psk@Solide@Viewpointy)*(\ra)-(\psk@Solide@Viewpointz)*(\rb)}%
\FPifpos{\Test}\ThreeDput[normal=0 {-\ra} {-\rb}](0,-\ra,-\rb){%
\psset{fillcolor=RougeD}\faceB\rput{144}{\rput(-1.8,0){\Calendrier[Mois=3]}}}\fi%
%face 5
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(\rc)+(\psk@Solide@Viewpointy)*(0)+(\psk@Solide@Viewpointz)*(\rd)}%
\FPifpos{\Test}\ThreeDput[normal={\rc} 0  {\rd}](\rc,0,\rd){%
\psset{fillcolor=RougeE}\faceB\rput(-1.8,0){\Calendrier[Mois=12]}}\fi
%face6
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(-\rc)+(\psk@Solide@Viewpointy)*(0)+(\psk@Solide@Viewpointz)*(\rd)}%
\FPifpos{\Test}\ThreeDput[normal={-\rc} 0  {\rd}](-\rc,0,\rd){%
\psset{fillcolor=RougeF}\faceB\rput{0}{\rput(-1.8,0){\Calendrier[Mois=7]}}}\fi
%face7
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(\rc)+(\psk@Solide@Viewpointy)*(0)-(\psk@Solide@Viewpointz)*(\rd)}%
\FPifpos{\Test}\ThreeDput[normal={\rc} 0 {-\rd}](\rc,0,-\rd){%
\psset{fillcolor=RougeG}\faceA\rput{180}{\rput(-1.8,0){\Calendrier[Mois=2]}}}\fi
%face8
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(-\rc)+(\psk@Solide@Viewpointy)*(0)-(\psk@Solide@Viewpointz)*(\rd)}%
\FPifpos{\Test}\ThreeDput[normal={-\rc} 0 {-\rd}](-\rc,0,-\rd){%
\psset{fillcolor=RougeH}\faceA\rput{108}{\rput(-1.8,0){\Calendrier[Mois=1]}}}\fi%
%face 9
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(\rd)+(\psk@Solide@Viewpointy)*(\rc)+(\psk@Solide@Viewpointz)*(0)}%
\FPifpos{\Test}\ThreeDput[normal={\rd} {\rc} 0](\rd,\rc,0){%
\psset{fillcolor=RougeI}\faceC\rput{18}{\rput(-1.8,0){\Calendrier[Mois=10]}}}\fi
%face10
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(-\rd)+(\psk@Solide@Viewpointy)*(\rc)+(\psk@Solide@Viewpointz)*(0)}%
\FPifpos{\Test}\ThreeDput[normal={-\rd} {\rc} 0](-\rd,\rc,0){%
\psset{fillcolor=RougeJ}\faceD\rput{198}{\rput(-1.8,0){\Calendrier[Mois=5]}}}\fi
%face11
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(\rd)-(\psk@Solide@Viewpointy)*(\rc)+(\psk@Solide@Viewpointz)*(0)}%
\FPifpos{\Test}\ThreeDput[normal={\rd} {-\rc} 0](\rd,-\rc,0){%
\psset{fillcolor=RougeK}\faceD\rput{-18}{\rput(-1.8,0){\Calendrier[Mois=9]}}}\fi
%face8
\FPeval{\Test}{(\psk@Solide@Viewpointx)*(-\rd)+(\psk@Solide@Viewpointz)*(0)-(\psk@Solide@Viewpointy)*(\rc)}%
\FPifpos{\Test}\ThreeDput[normal={-\rd} {-\rc} 0](-\rd,-\rc,0){%
\psset{fillcolor=RougeL}\faceC\rput{162}{\rput(-1.8,0){\Calendrier[Mois=4]}}}\fi%
\endpspicture
}}
%
\define@key{psset}{Jour}{\edef\psk@CalendrierJ{#1}}
\define@key{psset}{MoisChoisi}{\edef\psk@CalendrierMchoix{#1}}
\define@key{psset}{Mois}{\edef\psk@CalendrierM{#1}}
\define@key{psset}{An}{\edef\psk@CalendrierA{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setkeys{psset}{Jour=\number\day,Mois=\number\month,MoisChoisi=\number\month,An=\number\year}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
\newcount\colonne\newcount\ligne

\def\Calendrier{\@ifnextchar[{\pst@Calendrier}{\pst@Calendrier[]}}

\def\pst@Calendrier[#1]{{%
\setkeys{psset}{#1}
% calcul de la date de Pâques
% lundi de Pâques
\FPset{\Year}{\psk@CalendrierA}
\FPeval\GY{(\Year)-19*trunc((\Year)/19,0)}
\FPeval{\Cent}{trunc((\Year)/100,0)}
\FPeval{\Iter}{trunc((\Cent)-trunc((\Cent)/4,0)-trunc((8*(\Cent)+13)/25,0)+
                (\GY)*19+15,0)}
\FPeval{\Iterdiv}{trunc((\Iter)/30,0)}
\FPeval\Hepact{(\Iter)-30*(\Iterdiv)}
\FPeval\Inbre{trunc((\Hepact)-trunc((\Hepact)/28,0)*
              (1-trunc((\Hepact)/28,0))*(trunc(29/((\Hepact)+1),0)*trunc((21-(\GY))/11,0)),0)}
\FPeval\Jnbreinter{trunc((\Year)+trunc((\Year)/4,0)+(\Inbre)+2-(\Cent)+trunc((\Cent)/4,0),0)}
\FPeval\Jnbre{trunc((\Jnbreinter)-7*trunc((\Jnbreinter)/7,0),0)}
\FPeval\Lnbre{trunc((\Inbre)-(\Jnbre),0)}
\FPeval\Month{trunc(3+trunc(((\Lnbre)+40)/44,0),0)}
\FPeval\Day{trunc((\Lnbre)+28-31*trunc((\Month)/4,0),0)}
\ifnum\Month=4
  \ifnum\Day>25 \FPeval{\Day}{trunc((\Day)-7,0)} % dimanche de Pâques
%  \ifnum\Day>25 \FPeval{\Day}{trunc((\Day)-6,0)} % Lundi de Pâques
%    \else
%    \FPeval{\Day}{trunc((\Day)+1,0)} % Lundi  de Pâques
    \fi
\fi
\ifnum\Month=3
  \ifnum\Day=32 \FPset{\Day}{1}\FPset{\Month}{4}%
%    \else
%    \FPeval{\Day}{trunc((\Day)+1,0)} % Lundi
    \fi
\fi
%
% calcul du jour de l'ascension
% si Pâques tombe au mois d'avril, faire (39-30)+\Day = 9+\Day
% pour le jour du mois de mai de l'ascension
\ifnum\Month=4
\FPeval\DayAscension{trunc((\Day)+9,0)}
\FPeval\MonthAscension{trunc((\Month)+1,0)}
% Ascension le \FPprint\DayAscension/\FPprint\MonthAscension/\FPprint\Year
\FPeval\TestJourPentecote{trunc((\DayAscension)+10,0)}
  \ifnum\TestJourPentecote>31
    \FPeval\DayPentecote{trunc((\TestJourPentecote)-31,0)}
    \FPeval\MonthPentecote{trunc((\Month)+2,0)}
  \else
    \FPset{\DayPentecote}{\TestJourPentecote}
    \FPset\MonthPentecote{\MonthAscension}
  \fi

% Pentec\^ote le \FPprint\DayPentecote/\FPprint\MonthPentecote/\FPprint\Year
\fi

% Dans le cas où Pâques tombe en mars
% (39-30)+\Day=8+\Day
% si 8+\Day<ou=30 on reste en avril
% \DayAscension=8+\Day
% \MonthAscension=4
% Pentcôte est 10 jours après l'ascension
\ifnum\Month=3
\FPeval\TestSiJourAvril{trunc((\Day)+8,0)}
\ifnum\TestSiJourAvril<30
  \FPeval\MonthAscension{trunc((\Month)+1,0)}
  \FPeval\DayAscension{trunc(8+(\Day),0)}
  \else
  \FPeval\DayAscension{trunc((\Day)-22,0)}
  \FPeval\MonthAscension{trunc((\Month)+2,0)}
\fi
  \FPeval\TestJourPentecote{trunc((\DayAscension)+10,0)}
    \ifnum\MonthAscension=4
    \ifnum\TestJourPentecote<31
      \FPset{\DayPentecote}{\TestJourPentecote}
      \FPset\MonthPentecote{4}
    \else
      \FPeval\DayPentecote{trunc((\TestJourPentecote)-30,0)}
      \FPset\MonthPentecote{5}
    \fi
    \fi
  \ifnum\MonthAscension=5
    \FPeval\DayPentecote{trunc((\DayAscension)+10,0)}
    \FPset\MonthPentecote{5}
  \fi
\fi
%
% test d'une année bissextile
\FPeval{\YearBissextil}{(\psk@CalendrierA)/4}
\FPtrunc{\YearBissextil}{\YearBissextil}{0}
\FPeval{\YearBissextil}{(\YearBissextil)*4}
\FPtrunc{\YearBissextil}{\YearBissextil}{0}
%
\ifnum\psk@CalendrierM=1\def\adddays{0}\def\Name{JANVIER}\def\NbreJours{31}\fi
\ifnum\psk@CalendrierM=2\def\adddays{31}\def\Name{FEVRIER}
  \ifnum\YearBissextil=\psk@CalendrierA\def\NbreJours{29}\else\def\NbreJours{28}
\fi\fi
\ifnum\psk@CalendrierM=3
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{60}\else\def\adddays{59}\fi
\def\Name{MARS}\def\NbreJours{31}\fi
\ifnum\psk@CalendrierM=4
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{91}\else\def\adddays{90}\fi
\def\Name{AVRIL}\def\NbreJours{30}\fi
\ifnum\psk@CalendrierM=5
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{121}\else\def\adddays{120}\fi
\def\Name{MAI}\def\NbreJours{31}\fi
\ifnum\psk@CalendrierM=6
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{152}\else\def\adddays{151}\fi
\def\Name{JUIN}\def\NbreJours{30}\fi
\ifnum\psk@CalendrierM=7
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{182}\else\def\adddays{181}\fi
\def\Name{JUILLET}\def\NbreJours{31}\fi
\ifnum\psk@CalendrierM=8
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{213}\else\def\adddays{212}\fi
\def\Name{AOUT}\def\NbreJours{31}\fi
\ifnum\psk@CalendrierM=9
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{244}\else\def\adddays{243}\fi
\def\Name{SEPTEMBRE}\def\NbreJours{30}\fi
\ifnum\psk@CalendrierM=10
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{274}\else\def\adddays{273}\fi
\def\Name{OCTOBRE}\def\NbreJours{31}\fi
\ifnum\psk@CalendrierM=11
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{305}\else\def\adddays{304}\fi
\def\Name{NOVEMBRE}\def\NbreJours{30}\fi
\ifnum\psk@CalendrierM=12
  \ifnum\YearBissextil=\psk@CalendrierA\def\adddays{335}\else\def\adddays{334}\fi
\def\Name{DECEMBRE}\def\NbreJours{31}\fi
%
\ifnum\YearBissextil=\psk@CalendrierA
    \FPeval{\NbYearBissextil}{((\psk@CalendrierA)-2000)/4}
    \FPtrunc{\NbYearBissextil}{\NbYearBissextil}{0}
        \else
    \FPeval{\NbYearBissextil}{((\psk@CalendrierA)-2000)/4+1}
    \FPtrunc{\NbYearBissextil}{\NbYearBissextil}{0}
\fi
% le 1 janvier 2000 est un samedi : Nbdays=6
\FPeval{\NbDays}{6+((\psk@CalendrierA)-2000)+(\NbYearBissextil)+(\adddays)}
%
\FPtrunc{\NbDays}{\NbDays}{0}
%
\FPeval{\Frac}{(\NbDays)/7}
\FPtrunc{\Frac}{\Frac}{0}
%
\FPeval{\Quotient}{(\Frac)*7}
\FPtrunc{\Quotient}{\Quotient}{0}
%
\FPeval{\firstDay}{(\NbDays)-({\Quotient})}
%
\FPclip{\firstDay}{\firstDay}
\FPifzero\firstDay\FPset{\firstDay}{7}\fi
\ligne=2
\colonne=\firstDay
\pspicture(0,-4)(8,4)
\psframe*[linecolor=blue](0.5,3.2)(7.5,4)
\rput(4,3.6){\textcolor{white}{\textsf{\textbf{\huge\Name}}}}
\rput(1,2.8){\textsf{\textbf{\Large L}}}
\rput(2,2.8){\textsf{\textbf{\Large M}}}
\rput(3,2.8){\textsf{\textbf{\Large M}}}
\rput(4,2.8){\textsf{\textbf{\Large J}}}
\rput(5,2.8){\textsf{\textbf{\Large V}}}
\rput(6,2.8){\textsf{\textbf{\Large S}}}
\rput(7,2.8){\textsf{\textbf{\Large D}}}
\multido{\i=\firstDay+1}{\NbreJours}{%
\ifnum\i>7\ligne=1\fi
\ifnum\i>14\ligne=0\fi
\ifnum\i>21\ligne=-1\fi
\ifnum\i>28\ligne=-2\fi
\ifnum\i>35\ligne=-3\fi
  \ifnum\psk@CalendrierM=\psk@CalendrierMchoix
    \ifnum\the\multidocount=\psk@CalendrierJ
      \rput(\colonne,\ligne){%
      \pscirclebox[linestyle=none,fillstyle=solid,fillcolor=yellow]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}
     \else\rput(\colonne,\ligne){\textbf{\Large\the\multidocount}}
    \fi
      \else\rput(\colonne,\ligne){\textbf{\Large\the\multidocount}}
  \fi
% les jours fériés
% le 1 de l'an
    \ifnum\psk@CalendrierM=1
    \ifnum\the\multidocount=1
      \rput(\colonne,\ligne){\psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}
    \fi\fi
% le 1 mai et  8 mai
    \ifnum\psk@CalendrierM=5
    \ifnum\the\multidocount=1
      \rput(\colonne,\ligne){\psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}%
    \fi
    \ifnum\the\multidocount=8
      \rput(\colonne,\ligne){\psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}%
      \fi
    \fi
% 15 août
    \ifnum\psk@CalendrierM=8
    \ifnum\the\multidocount=15
      \rput(\colonne,\ligne){%
          \psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}
    \fi\fi
% 1 Novembre et 11 Novembre
   \ifnum\psk@CalendrierM=11
    \ifnum\the\multidocount=1
      \rput(\colonne,\ligne){%
          \psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}
    \fi
    \ifnum\the\multidocount=11
      \rput(\colonne,\ligne){%
          \psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}
      \fi
    \fi
% Noël
    \ifnum\psk@CalendrierM=12
    \ifnum\the\multidocount=25
      \rput(\colonne,\ligne){%
          \psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}
    \fi\fi
% Dimanche de Pâques
    \ifnum\psk@CalendrierM=\Month
    \ifnum\the\multidocount=\Day
      \rput(\colonne,\ligne){%
          \psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}
    \fi\fi
% Ascension
    \ifnum\psk@CalendrierM=\MonthAscension
    \ifnum\the\multidocount=\DayAscension
      \rput(\colonne,\ligne){%
          \psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}
    \fi\fi
% Pentecôte
    \ifnum\psk@CalendrierM=\MonthPentecote
    \ifnum\the\multidocount=\DayPentecote
      \rput(\colonne,\ligne){%
          \psframebox[style=holiday]{\textbf{\textcolor{red}{\Large\the\multidocount}}}}
    \fi\fi
%
\advance\colonne by +1
\ifnum\colonne>7\colonne=1\fi}
\rput(4,-3.5){\psovalbox[fillstyle=solid,fillcolor=blue,linestyle=none]{\textcolor{white}{\textsf{\textbf{\huge\psk@CalendrierA}}}}}
\multido{\rL=-2.5+1.0}{6}{\psline[linecolor=blue](0.5,\rL)(7.5,\rL)}
\endpspicture}}
%
%% END: CalendrierFP.sty
\endinput
