From 9aa3e3f24c18562e39168cdd629ed1019a4ac317 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 3 Sep 2011 20:15:27 +0200 Subject: shack is-plenum: initial commit --- shack/bin/is-plenum | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 shack/bin/is-plenum (limited to 'shack') diff --git a/shack/bin/is-plenum b/shack/bin/is-plenum new file mode 100755 index 00000000..1c686ca1 --- /dev/null +++ b/shack/bin/is-plenum @@ -0,0 +1,34 @@ +#! /bin/sh +# +# //shack/is-plenum [YEAR] +# +# where YEAR defaults to the current year +# + +y=${1-`date +%Y`} +for m in `seq 1 12`; do + t1= + t2= + t3= + t4= + t5= + week_done=-1 + for d in `cal $m $y | tr ' ' '\n' | grep '^[0-9][0-9]\?$'`; do + echo $m | grep -q '^.$' && m=0$m + echo $d | grep -q '^.$' && d=0$d + date=$y-$m-$d + date_week=`date -d $date +%W` + if test $week_done -lt $date_week; then + test -z "$t1" && { test `date -d $date +%u` = 4 && t1=$date && week_done=$date_week; continue; } + test -z "$t2" && { test `date -d $date +%u` = 3 && t2=$date && week_done=$date_week; continue; } + test -z "$t3" && { test `date -d $date +%u` = 4 && t3=$date && week_done=$date_week; continue; } + test -z "$t4" && { test `date -d $date +%u` = 3 && t4=$date && week_done=$date_week; continue; } + test -z "$t5" && { test `date -d $date +%u` = 3 && t5=$date && week_done=$date_week; continue; } + fi + done + test -n "${t1}" && echo $t1 + test -n "${t2}" && echo $t2 + test -n "${t3}" && echo $t3 + test -n "${t4}" && echo $t4 + test -n "${t5}" && echo $t5 +done -- cgit v1.2.3