From 483810a525b138f91dcb11f5864817a6e9ba6699 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 31 Jan 2007 16:53:31 +0000 Subject: 23142: calendar enhancements: relative times, recurring events --- Functions/Calendar/calendar_showdate | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Functions/Calendar/calendar_showdate (limited to 'Functions/Calendar/calendar_showdate') diff --git a/Functions/Calendar/calendar_showdate b/Functions/Calendar/calendar_showdate new file mode 100644 index 000000000..b35a0a91f --- /dev/null +++ b/Functions/Calendar/calendar_showdate @@ -0,0 +1,48 @@ +emulate -L zsh +setopt extendedglob + +local optm datefmt +integer optr replyset + +zstyle -s ':datetime:calendar_showdate:' date-format datefmt || + datefmt="%a %b %d %H:%M:%S %Z %Y" + +if [[ $1 = -r ]]; then + shift + REPLY=0 + optr=1 +else + local REPLY +fi + +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 -- cgit 1.4.1