summaryrefslogtreecommitdiff
path: root/Functions/Calendar/calendar_showdate
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-03-26 14:33:31 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-03-26 14:33:31 +0000
commit4b7b7f56f1cde7e317fce378d0d0e5c83686ff72 (patch)
tree2420ad49f480b9c2de0c3f13da7bca9f8a415678 /Functions/Calendar/calendar_showdate
parent7072c10ae223e24f601b3ee99e89dfcc35397122 (diff)
downloadzsh-4b7b7f56f1cde7e317fce378d0d0e5c83686ff72.tar.gz
zsh-4b7b7f56f1cde7e317fce378d0d0e5c83686ff72.zip
unposted: more random calendar system fixes and improvements
Diffstat (limited to 'Functions/Calendar/calendar_showdate')
-rw-r--r--Functions/Calendar/calendar_showdate32
1 files changed, 28 insertions, 4 deletions
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