From 4b7b7f56f1cde7e317fce378d0d0e5c83686ff72 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 26 Mar 2007 14:33:31 +0000 Subject: unposted: more random calendar system fixes and improvements --- Functions/Calendar/calendar_showdate | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'Functions/Calendar/calendar_showdate') diff --git a/Functions/Calendar/calendar_showdate b/Functions/Calendar/calendar_showdate index 69588da4f..a8985513c 100644 --- a/Functions/Calendar/calendar_showdate +++ b/Functions/Calendar/calendar_showdate @@ -8,15 +8,39 @@ integer optr replyset zstyle -s ':datetime:calendar_showdate:' date-format datefmt || datefmt="%a %b %d %H:%M:%S %Z %Y" -while [[ $argv[$OPTIND] != +* ]] && getopts "r" opt; do - case $opt in - (r) +# Memo to myself: both + and - are documented as giving relative +# times, so it's not a good idea to rewrite this to use getopts. +# We need to detect the small number of options this can actually +# handle. +while [[ $1 = -r || $1 = -- || $1 = -f* ]]; do + case $1 in + (-r) + shift REPLY=0 optr=1 ;; + + (-f*) + if [[ $1 = -f?* ]]; then + datefmt=$1[3,-1] + shift + else + shift + if [[ -z $1 || $1 != *%* ]]; then + print "$0: -f requires a date/time specification" >&2 + return 1 + fi + datefmt=$1 + shift + fi + ;; + + (--) + shift + break + ;; esac done -shift $(( OPTIND - 1 )) (( optr )) || local REPLY -- cgit 1.4.1