2007-01-31 17:53:31 +01:00
|
|
|
emulate -L zsh
|
|
|
|
setopt extendedglob
|
2007-03-23 00:52:26 +01:00
|
|
|
zmodload -i zsh/datetime
|
2007-01-31 17:53:31 +01:00
|
|
|
|
2007-03-23 00:52:26 +01:00
|
|
|
local optm datefmt opt
|
2007-01-31 17:53:31 +01:00
|
|
|
integer optr replyset
|
|
|
|
|
|
|
|
zstyle -s ':datetime:calendar_showdate:' date-format datefmt ||
|
|
|
|
datefmt="%a %b %d %H:%M:%S %Z %Y"
|
|
|
|
|
2007-03-23 00:52:26 +01:00
|
|
|
while [[ $argv[$OPTIND] != +* ]] && getopts "r" opt; do
|
|
|
|
case $opt in
|
|
|
|
(r)
|
|
|
|
REPLY=0
|
|
|
|
optr=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(( OPTIND - 1 ))
|
|
|
|
|
|
|
|
(( optr )) || local REPLY
|
2007-01-31 17:53:31 +01:00
|
|
|
|
|
|
|
if (( ! $# )); then
|
|
|
|
print "Usage: $0 datespec [ ... ]" >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
while (( $# )); do
|
|
|
|
optm=
|
|
|
|
if [[ $1 = [-+]* ]]; then
|
|
|
|
# relative
|
|
|
|
[[ $1 = -* ]] && optm=-m
|
|
|
|
1=${1[2,-1]}
|
|
|
|
# if this is the first argument, use current time
|
|
|
|
# don't make assumptions about type of reply in case global
|
|
|
|
if (( ! replyset )); then
|
|
|
|
REPLY=$EPOCHSECONDS
|
|
|
|
replyset=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( replyset )); then
|
|
|
|
calendar_scandate $optm -R $REPLY -aA $1 || return 1
|
|
|
|
replyset=1
|
|
|
|
else
|
|
|
|
calendar_scandate -aA $1 || return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
(( optr )) && return
|
|
|
|
strftime $datefmt $REPLY
|