From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4569 invoked from network); 19 Feb 2008 14:47:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.4 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 19 Feb 2008 14:47:53 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 58473 invoked from network); 19 Feb 2008 14:47:45 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 19 Feb 2008 14:47:45 -0000 Received: (qmail 6641 invoked by alias); 19 Feb 2008 14:47:42 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24572 Received: (qmail 6631 invoked from network); 19 Feb 2008 14:47:41 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 19 Feb 2008 14:47:41 -0000 Received: from cluster-g.mailcontrol.com (cluster-g.mailcontrol.com [85.115.41.190]) by bifrost.dotsrc.org (Postfix) with ESMTP id 103B08026E0B for ; Tue, 19 Feb 2008 15:47:37 +0100 (CET) Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly02g.srv.mailcontrol.com (MailControl) with ESMTP id m1JEk2AM027230 for ; Tue, 19 Feb 2008 14:47:27 GMT Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Tue, 19 Feb 2008 14:47:11 +0000 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.14.2/8.13.4) with ESMTP id m1JElAja027593 for ; Tue, 19 Feb 2008 14:47:11 GMT Received: from csr.com (pws@localhost) by news01.csr.com (8.14.2/8.14.2/Submit) with ESMTP id m1JEl8rB027588 for ; Tue, 19 Feb 2008 14:47:10 GMT X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: PATCH: reformat date in calendar_add X-Mailer: MH-E 8.0.3; nmh 1.2-20070115cvs; GNU Emacs 22.1.1 Date: Tue, 19 Feb 2008 14:47:07 +0000 Message-ID: <27587.1203432427@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 19 Feb 2008 14:47:11.0749 (UTC) FILETIME=[4F4CCB50:01C87306] X-Scanned-By: MailControl A-08-00-04 (www.mailcontrol.com) on 10.71.0.112 X-Virus-Scanned: ClamAV 0.91.2/5886/Tue Feb 19 09:09:14 2008 on bifrost X-Virus-Status: Clean I thought I'd already added this and my .zshenv seemed to think so, too. Index: Doc/Zsh/calsys.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/calsys.yo,v retrieving revision 1.12 diff -u -r1.12 calsys.yo --- Doc/Zsh/calsys.yo 1 Feb 2008 19:59:47 -0000 1.12 +++ Doc/Zsh/calsys.yo 19 Feb 2008 14:24:39 -0000 @@ -440,6 +440,10 @@ calendar file as it is already locked. These options will not usually be needed by users. +If the style tt(reformat-date) is true, the date and time of the +new entry will be rewritten into the standard date format: see +the descriptions of this style and the style tt(date-format). + The function can use a unique identifier stored with each event to ensure that updates to existing events are treated correctly. The entry should contain the word tt(UID), followed by whitespace, followed by @@ -624,6 +628,14 @@ The style may be set to an empty string in which case a "done" file will not be maintained. ) +kindex(reformat-date) +item(tt(reformat-date))( +Boolean, used by tt(calendar_add). If it is true, the date and time +of new entries added to the calendar will be reformatted to the format +given by the style tt(date-format) or its default. Only the date and +time of the event itself is reformatted; any subsidiary dates and times +such as those associated with repeat and warning times are left alone. +) kindex(show-prog) item(tt(show-prog))( The programme run by tt(calendar) for showing events. It will Index: Functions/Calendar/calendar_add =================================================================== RCS file: /cvsroot/zsh/zsh/Functions/Calendar/calendar_add,v retrieving revision 1.8 diff -u -r1.8 calendar_add --- Functions/Calendar/calendar_add 7 Feb 2008 02:11:00 -0000 1.8 +++ Functions/Calendar/calendar_add 19 Feb 2008 14:24:39 -0000 @@ -8,6 +8,8 @@ emulate -L zsh setopt extendedglob +local context=":datetime:calendar_add:" + local calendar newfile REPLY lastline opt local -a calendar_entries lockfiles reply integer my_date done rstat nolock nobackup new_recurring old_recurring @@ -33,17 +35,25 @@ shift $(( OPTIND - 1 )) # Read the calendar file from the calendar-file style -zstyle -s ':datetime:calendar_add:' calendar-file calendar || +zstyle -s $context calendar-file calendar || calendar=~/calendar newfile=$calendar.new.$HOST.$$ -if ! calendar_parse "$*"; then +local addline="$*" +if ! calendar_parse $addline; then print "$0: failed to parse date/time" >&2 return 1 fi parse_new=("${(@kv)reply}") (( my_date = $parse_new[time] )) [[ -n $parse_new[rpttime] ]] && (( new_recurring = 1 )) +if zstyle -t $context reformat-date; then + local datefmt + zstyle -s $context date-format datefmt || + datefmt="%a %b %d %H:%M:%S %Z %Y" + strftime -s REPLY $datefmt $parse_new[time] + addline="$REPLY $parse_new[text1]" +fi # $calendar doesn't necessarily exist yet. @@ -53,7 +63,7 @@ # Match a UID, a unique identifier for the entry inherited from # text/calendar format. local uidpat='(|*[[:space:]])UID[[:space:]]##(#b)([[:xdigit:]]##)(|[[:space:]]*)' -if [[ "$*" = ${~uidpat} ]]; then +if [[ $addline = ${~uidpat} ]]; then my_uid=${(U)match[1]} fi @@ -82,7 +92,7 @@ calendar_parse $line || continue parse_old=("${(@kv)reply}") if (( ! done && ${parse_old[time]} > my_date )); then - print -r -- "$*" + print -r -- $addline (( done = 1 )) fi if [[ -n $parse_old[rpttime] ]]; then @@ -119,13 +129,13 @@ fi fi fi - if [[ $REPLY -eq $my_date && $line = "$*" ]]; then + if [[ $parse_old[time] -eq $my_date && $line = $addline ]]; then (( done )) && continue # paranoia: shouldn't happen (( done = 1 )) fi print -r -- $line done - (( done )) || print -r -- "$*" + (( done )) || print -r -- $addline } >$newfile if (( ! nobackup )); then if ! mv $calendar $calendar.old; then -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070