From 7f1c5618c5fd7607548d20394c749dc93adb78d7 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sat, 24 Aug 2013 22:05:53 -0400 Subject: [PATCH] Fix it so that items roll off and only notify 15 minutes. --- org-mode-appt-check.plx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/org-mode-appt-check.plx b/org-mode-appt-check.plx index 3215849..75508f5 100755 --- a/org-mode-appt-check.plx +++ b/org-mode-appt-check.plx @@ -49,14 +49,16 @@ while (my $line = ) { $firstDay = $firstTime; $firstTime = 0; $dayLine = $line; + $dayLine =~ s/\s*W\d+\s*$//; $prettyDayLine = "\${color3}$dayLine\${color}\n"; } - if ($line =~ /^\s+(?:[^:]+)\s*:\s+(\d+)\s*:\s*(\d+)\s*[\-\.]+(.*)$/) { + elsif ($line =~ /^\s+(?:[^:]+)\s*:\s+(\d+)\s*:\s*(\d+)\s*[\-\.]+(.*)$/) { + my $date = ParseDate("$dayLine $1:$2"); if ($firstDay) { my $time = "$1:$2"; my $val = $3; - my $date = ParseDate("$dayLine $1:$2"); - if (DateCalc("$date", "+ 15 minutes") ge $now) { + if (DateCalc("$date", "+ 15 minutes") ge $now and + DateCalc("$now", "+ 15 minutes") gt $date) { my $fh = File::Temp->new(); $fh->unlink_on_destroy( 1 ); my $fname = $fh->filename; @@ -69,6 +71,7 @@ while (my $line = ) { 'Appointment', "You have an appointment at $time: $val"); } } + next if DateCalc("$date", "+ 1 hour") lt $now; if (defined $prettyDayLine) { print $prettyDayLine; undef $prettyDayLine;