zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: calendar: repeated events from ages ago
@ 2008-11-20 16:52 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2008-11-20 16:52 UTC (permalink / raw)
  To: Zsh hackers list

Now that I've noticed this is lying around...

Repeated events in calendar entries (RPT keyword) are always updated
precisely once, not until they are in the future.  This fixes that, but
it does it the obvious way so if you're repeating events started a
really long time ago this will take a while.

Lightly tested but unlikely to be further tested until it fails horribly.

Index: Functions/Calendar/calendar_parse
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Calendar/calendar_parse,v
retrieving revision 1.1
diff -u -r1.1 calendar_parse
--- Functions/Calendar/calendar_parse	29 Nov 2007 09:49:43 -0000	1.1
+++ Functions/Calendar/calendar_parse	20 Nov 2008 16:49:36 -0000
@@ -28,6 +28,7 @@
 
 local REPLY REPLY2
 local -a match mbegin mend
+integer now
 
 autoload -U calendar_scandate
 
@@ -70,6 +71,17 @@
       reply[rpttime]=$REPLY
       reply[rptstr]=${match[2]%%"$REPLY2"}
       reply[text2]="${match[1]}${REPLY2##[[:space:]]#}"
+      (( now = EPOCHSECONDS ))
+      while (( ${reply[rpttime]} < now )); do
+	# let's hope the original appointment wasn't in 44 B.C.
+	if calendar_scandate -a -R ${reply[rpttime]} ${reply[rptstr]}; then
+	  if (( REPLY <= ${reply[rpttime]} )); then
+	    # pathological case
+	    break;
+	  fi
+	  reply[rpttime]=$REPLY
+	fi
+      done
     else
       # Just remove the keyword for further parsing
       reply[text2]="${match[1]}${match[2]##[[:space:]]#}"


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-20 16:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-20 16:52 PATCH: calendar: repeated events from ages ago Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).