]> git.plutz.net Git - shellwiki/blobdiff - macros/calendar
avoid extra img margins in floating figures
[shellwiki] / macros / calendar
index a8f8dd649019e4b38daf8ab8e73b374684d47745..b05c264813f1eddca117c1b29c79ca48ed02e3c1 100755 (executable)
@@ -43,7 +43,7 @@ while [ $# -gt 0 ]; do case $1 in
     fi;;
 esac; done
 
-[ "$*" ] || set -- "*"
+[ "$*" ] || set -- "."
 [ "$depth" -ge 0 -o "$depth" -le 0 ] 2>&- || depth=0
 
 read DY DM DD <<-EOF
@@ -52,6 +52,7 @@ read DY DM DD <<-EOF
          || date -u +"%Y %m %d"
        )
        EOF
+DM=${DM#0}; DD="${DD#0}"; DY="${DY#0}"
 
 case $ws in
   0|[sS]*) ws=0;;
@@ -68,6 +69,7 @@ rrexpand() {
   local junk1 start end rrfreq rrint rrend evtitle evlink junk2
 
   while read -r junk1 start end rrfreq rrint rrend evtitle evlink junk2; do
+    [ ! "$start" ] && continue  # empty line
     [ "$rrend" -eq -1 ] && rrend=9999999999
 
     if [ "$start" -lt "$dend" ] &&
@@ -237,7 +239,7 @@ events="$(
 
 cal_list() {
   # Print list view for upcoming events
-  local lday='' events sdate=$(date -ud "${DY}-${DM}-${DD}" +%s)
+  local lday='' events="$events" sdate=$(date -ud "${DY}-${DM}-${DD}" +%s)
 
   events="$(
     printf %s\\n "$events" \
@@ -261,7 +263,7 @@ cal_list() {
 }
 
 cal_month() {
-  local ws events calmonth
+  local ws="$ws" events="$events" calmonth
   local iday idow mname dcnt dow dcal start end title link n
 
   calmonth="$(GET calmonth || printf %i "$((DY * 12 + DM))")"
@@ -274,7 +276,6 @@ cal_month() {
   dcnt=$((iday - idow * 86400 + ws * 86400))
    dow=$ws
   dcal="$(date -ud @"$dcnt" +%d)"
-
   events="$(
     printf %s\\n "$events" \
     | rrexpand "$dcnt" "$((dcnt + 42 * 86400))" \
@@ -299,7 +300,7 @@ cal_month() {
             "$(UNSTRING "${link#*#}" |URL)" \
             "$(UNSTRING "$title" |HTML)"
         elif [ "$((start / 86400))" -eq "$((dcnt / 86400))" ]; then
-          printf '<li>%s - <a href="%s\#%s">%s</a></li>' \
+          printf '<li>%s - <a href="%s#%s">%s</a></li>' \
             "$(date -ud @"$start" +%H:%M)" \
             "$(UNSTRING "${link%%#*}" |URL)" \
             "$(UNSTRING "${link#*#}" |URL)" \