URL:
https://svn.lrde.epita.fr/svn/lrdetools/trunk
ChangeLog:
2007-02-17 mefyl <mefyl(a)lrde.epita.fr>
Add mail from ics generator.
* ics2mail/weekly.sh: New.
diffstat not available
Index: trunk/ics2mail/weekly.sh
===================================================================
--- trunk/ics2mail/weekly.sh (revision 0)
+++ trunk/ics2mail/weekly.sh (revision 419)
@@ -0,0 +1,80 @@
+#FIRSTNAME=quentin
+#LASTNAME=hocquet
+#PASSWD=********
+
+START=$(
+ if [ $(date +%A) = "Monday" ]; then
+ date +%Y%m%d
+ else
+ date --date='last monday' +%Y%m%d
+ fi
+)
+END=$(
+ if [ $(date +%A) = "Sunday" ]; then
+ date +%Y%m%d
+ else
+ date --date='next sunday' +%Y%m%d
+ fi
+)
+
+capitalize ()
+{
+ min="$1"
+ maj="$(echo "$min" | tr a-z A-Z)"
+ echo -n "$maj" | sed 's/^\(.\).*/\1/'
+ echo -n "$min" | sed 's/^.\(.*\)/\1/'
+}
+
+cal="$(mktemp)"
+wget -q --no-check-certificate https://$(capitalize "$FIRSTNAME")$(capitalize
"$LASTNAME"):$PASSWD@www.lrde.epita.fr/cal/"$FIRSTNAME"."$LASTNAME".ics
-O "$cal"
+
+echo "Occupation du temps pour $(capitalize "$FIRSTNAME") $(capitalize
"$LASTNAME")"
+echo "Détail disponible sur
http://www.lrde.epita.fr/cal/$FIRSTNAME.$LASTNAME.ics"
+echo
+
+awk '
+BEGIN {p = 0}
+/END:VEVENT/ {
+ if (valid)
+ {
+ p = 0
+ start = int(start / 100)
+ end = int(end / 100)
+ t = (int(end / 100) - int(start / 100)) * 60 - (start % 100) + (end % 100)
+ table[text] += t
+ }
+}
+
+p && /^SUMMARY:/ {
+ text = substr($0,9)
+}
+
+p && /^DTSTART:/ {
+ date = substr($0, 9, 8)
+ if (date >= '$START' && date <= '$END')
+ valid = 1
+ else
+ valid = 0
+ start = substr($0, 18, 6)
+}
+
+p && /^DTEND:/ {
+ end = substr($0, 16, 6)
+}
+
+/BEGIN:VEVENT/ {p = 1}
+
+END {
+ for (i in table)
+ {
+ h = int(table[i] / 60)
+ mn = (table[i] % 60)
+ if (mn == 0)
+ mn = ""
+ print i ": " h "h" mn
+ }
+}
+' "$cal" | sed 's/é/é/g'
+# if anyone can convert UTF8 to ascii automatically ... I didn't manage to.
+
+rm "$cal"
Property changes on: trunk/ics2mail/weekly.sh
___________________________________________________________________
Name: svn:executable
+ *
--
|mefyl <hocque_q - Epita 2008 - LRDE, Yaka, Evolutek>
| Si tu ne parviens pas à tirer de l'eau d'un puits, (o_ (o_
| n'en déduis pas qu'il est vide, mais que peut être (o_ //\ //\
\____________ta corde est trop courte.__________________(/)__V_/___V_/_