commit e07a2c11f179b54c146d7b2cb035d8571b9c1db9
Author: Romuald <devnull@localhost>
Date:   Sat Apr 11 18:18:29 2009 +0200

    Version script de la gÃ©nÃ©ration du calendrier.

diff --git a/calendrier.css b/calendrier.css
new file mode 100644
index 0000000..2052202
--- /dev/null
+++ b/calendrier.css
@@ -0,0 +1,62 @@
+/*
+ * style sheet for gencal.sh Copyright (C) 2004 by Romuald DELAVERGNE
+*/
+body {
+	background-color: white;
+	color: black;
+}
+
+table {
+	border: medium solid #0000d0;
+	border-collapse: collapse;
+	width: 100%;
+}
+
+th {
+	color: white;
+	text-align: center;
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 20px;
+	text-transform: uppercase;
+	font-weight: bold;
+	width: 16%;
+}
+
+#mois1, #mois3, #mois5, #mois7, #mois9, #mois11 {
+	background-color: #0000d0;
+}
+
+#mois2, #mois4, #mois6, #mois8, #mois10, #mois12 {
+	background-color: #f00000;
+}
+
+td {
+	border: thin solid #0000d0;
+	color: #0000d0;
+}
+
+td.dimanche, td.samedi {
+	background-color: #d0d0ff;
+	color: #f00000;
+}
+
+td.ferie {
+	background-color: #a0a0ff;
+	color: #f00000;
+}
+
+span.nom-jour {
+	font-family: monospace;
+	font-size: 15px;
+	text-transform: uppercase;
+	float: left;
+}
+
+span.num-jour {
+	font-family: Arial, Helvetica, sans-serif;
+	font-size: 15px;
+	font-weight: bold;
+	text-align: right;
+	width: 1.5em;
+	float: left;
+}
diff --git a/gencal.sh b/gencal.sh
new file mode 100755
index 0000000..a39cda5
--- /dev/null
+++ b/gencal.sh
@@ -0,0 +1,153 @@
+#!/bin/bash
+#
+# Calendar generation script Copyright (C) 2004 by Romuald DELAVERGNE
+# It can be redistributed under the terms of the GNU General Public License.
+#
+
+# Pâques a lieu le 1er dimanche qui suit la pleine lune qui suit ou qui a lieu le jour de l'équinoxe du printemps (21 mars)
+function getPaquesDay() {
+	local b c d e f g h
+	local jour mois year=$1
+
+	b=$((year-1900))
+	c=$((year % 19))
+	d=$(((7*$c+1)/19))
+	e=$(((11*$c+4-$d) % 29))
+	f=$((b/4))
+	g=$(((b+$f+31-$e) % 7))
+	h=$((25-$e-$g))
+	if [ $h -gt 0 ]; then 
+		jour=$h
+		mois=4
+	else 
+		jour=$((h+31))
+		mois=3
+	fi
+	echo "$jour $mois"
+}
+
+lstJours=(none dimanche lundi mardi mercredi jeudi vendredi samedi)
+lstMois=(none janvier février mars avril mai juin juillet août septembre octobre novembre décembre)
+lstFeries=(jourDeLAn rameaux paques lundiDePaques feteDuTravail victoire1945 ascension pentecote lundiDePentecote feteNationale assomption toussaint armistice1918 noel)
+output=/tmp/calendrier.html
+year=${1:-`date +%Y`}
+
+# Jours fériés fixes
+jourDeLAn=(1 1 "jour de l'an")
+feteDuTravail=(1 5 "fête du travail")
+victoire1945=(8 5 "victoire 1945")
+feteNationale=(14 7 "fête Nationale")
+assomption=(15 8 "l'Assomption")
+toussaint=(1 11 "la Toussaint")
+armistice1918=(11 11 "armistice 1918")
+noel=(25 12 "Noël")
+# Pâques et ses dépendances
+paques=(`getPaquesDay $year` "Pâques")
+rameaux[0]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 7 days ago" +%-d`
+rameaux[1]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 7 days ago" +%-m`
+rameaux[2]="les Rameaux"
+lundiDePaques[0]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 1 day" +%-d`
+lundiDePaques[1]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 1 day" +%-m`
+lundiDePaques[2]="lundi de Pâques"
+ascension[0]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 39 days" +%-d`
+ascension[1]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 39 days" +%-m`
+ascension[2]="l'Ascension"
+pentecote[0]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 49 days" +%-d`
+pentecote[1]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 49 days" +%-m`
+pentecote[2]="la Pentecôte"
+lundiDePentecote[0]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 50 days" +%-d`
+lundiDePentecote[1]=`LANG=C date --date "${paques[1]}/${paques[0]}/$year 50 days" +%-m`
+lundiDePentecote[2]="lundi de Pentecôte"
+
+function firstDay() {
+	local month what line days nb
+
+	month=`LANG=C cal $1 $year`
+	what=""
+	echo -e "$month" | while read line; do
+		case "$what" in
+			"") what="month";;
+			"month") what="days";;
+			"days") what="week1";;
+			"week1") what="week";;
+		esac
+		if [ "$what" = "week1" ]; then
+			days=($line)
+			nb=${#days[@]}
+			echo "$((8-$nb))"
+			exit
+		fi
+	done
+}
+
+function lastDay() {
+	local month nb
+
+	month=(`LANG=C cal $1 $year`)
+	nb=${#month[@]}
+	echo "${month[$((nb-1))]}"
+}
+
+cat > $output << EOF
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
+  <head>
+    <meta http-equiv="Content-Type" content="text/HTML; charset=iso-8859-1"  />
+    <meta http-equiv="Content-style-type" content="text/css" />
+    <meta http-equiv="Content-language" content="fr" />
+    <title>Calendrier $year</title>
+    <link rel="stylesheet" type="text/css" href="calendrier.css" media="screen" title="Normal" />
+    <link rel="stylesheet" type="text/css" href="calendrier.css" media="print" title="Normal" />
+  </head>
+
+  <body>
+EOF
+
+for s in 1 2; do
+	echo "    <table>" >> $output
+	for j in `seq 0 31`; do
+		[ $j -eq 0 ] && echo "      <tr id=\"semestre$s\">" >> $output || echo "      <tr class=\"jour$j\">" >> $output
+		for m in `seq $((s*6-5)) $((s*6))`; do
+			if [ $j -eq 0 ]; then
+				echo "        <th id=\"mois$m\">${lstMois[$m]}</th>" >> $output
+				jour[$m]=`firstDay $m`
+				lstLast[$m]=`lastDay $m`
+			else
+				currentDay=${jour[$m]}
+				name=${lstJours[$currentDay]}
+				last=${lstLast[$m]}
+				if [ $j -le $last ]; then
+					classFerie=""
+					for f in ${lstFeries[*]}; do
+						eval jourFerie='${'$f'[0]}'
+						eval moisFerie='${'$f'[1]}'
+						eval libelleFerie='${'$f'[2]}'
+						if [ "$j" = "$jourFerie" -a "$m" = "$moisFerie" ]; then
+							classFerie=" class=\"ferie\" class=\"$f\" title=\"$libelleFerie\"" 
+							break
+						fi
+					done
+					echo "        <td$classFerie class=\"$name\"><span class=\"nom-jour\">${name:0:3}</span><span class=\"num-jour\">$j</span></td>" >> $output
+					[ ${jour[$m]} = 7 ] && jour[$m]=1 || jour[$m]=$((jour[$m]+1))
+				else
+					if [ $last -eq 30 ]; then
+						echo "        <td></td>" >> $output
+					else
+						[ $j -eq $((last+1)) ] && echo "        <td rowspan="$((31-last))"></td>" >> $output
+					fi
+				fi
+			fi
+		done
+		echo "      </tr>" >> $output
+	done
+	echo "    </table>" >> $output
+	echo "    <br>" >> $output
+done
+	
+cat >> $output << EOF
+  </body>
+</html>
+EOF
+
+exit 0
