X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=templates%2Fview_course.sh;h=23088f19e33edc83f5ead5a3bd15cdd67b5badbc;hb=0148cdea1cf6f906cc401885013da20774034d75;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=a8c6f8b510bb4747798c4f576162733d982bae75;p=lobster
diff --git a/templates/view_course.sh b/templates/view_course.sh
index e69de29..23088f1 100755
--- a/templates/view_course.sh
+++ b/templates/view_course.sh
@@ -0,0 +1,102 @@
+# Copyright 2014 Paul Hänsch
+#
+# This file is part of Confetti.
+#
+# Confetti is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Confetti is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with Confetti. If not, see .
+
+dtstart="$values[DTSTART]"
+[ -z "$dtstart" ] && dtstart=$(date +%Y%m%dT%H%M%S)
+
+echo "$dtstart" |case "$dtstart" in
+ *Z)
+ sed -rn 's:^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$:\1-\2-\3 \4\:\5\:\6 UTC:p'
+ ;;
+ TZID*)
+ sed -rn 's:^TZID=(.+)\:([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})$:TZ="\1" \2-\3-\4 \5\:\6\:\7:p'
+ ;;
+ *)
+ sed -rn 's:^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})$:\1-\2-\3 \4\:\5\:\6:p'
+ ;;
+esac |read dts_date
+
+dts_year=$(date -d "$dts_date" +%Y)
+dts_month=$(date -d "$dts_date" +%m)
+dts_dom=$(date -d "$dts_date" +%d)
+dts_dow=$(date -d "$dts_date" +%u)
+dts_weekday=$(date -d "$dts_date" +%A)
+dts_hour=$(date -d "$dts_date" +%H)
+dts_min=$(date -d "$dts_date" +%M)
+dts_sec=$(date -d "$dts_date" +%S)
+
+rrule="$values[RRULE]"
+rr_int="$(echo $rrule |sed -rn 's:^.*INTERVAL=([0-9]+)(;.*)?$:\1:p')"
+rr_count="$(echo $rrule |sed -rn 's:^.*COUNT=([0-9]+)(;.*)?$:\1:p')"
+rr_freq="$(echo $rrule |sed -rn 's:^.*FREQ=(YEARLY|MONTHLY|WEEKLY|DAILY)(;.*)?$:\1:p')"
+rr_uyear="$(echo $rrule |sed -rn 's:^.*UNTIL=([0-9]{4})([0-9]{2})([0-9]{2})T[0-9]{6}Z(;.*)?$:\1:p')"
+rr_umonth="$(echo $rrule |sed -rn 's:^.*UNTIL=([0-9]{4})([0-9]{2})([0-9]{2})T[0-9]{6}Z(;.*)?$:\2:p')"
+rr_uday="$(echo $rrule |sed -rn 's:^.*UNTIL=([0-9]{4})([0-9]{2})([0-9]{2})T[0-9]{6}Z(;.*)?$:\3:p')"
+rr_udate="$(echo $rrule |sed -rn 's:^.*UNTIL=([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z(;.*)?$:\1-\2-\3 \4\:\5\:\6:p')"
+if [ -n "$rr_count" ]; then
+ rr_limit=COUNT
+elif [ -n "$rr_uyear" ]; then
+ rr_limit=UNTIL
+else
+ rr_limit=ETERN
+fi
+
+coursemail=""
+
+echo '
'
+