Attached is a patch to allow for date handling in todo-text. Allan -- __^__ __^__ ( ___ )----------------------------------------( ___ ) | / | "Engineers aren't boring people, | \ | | / | we just get excited about boring things" | \ | |___| --Anon |___| (_____)----------------------------------------(_____)
--- /usr/local/libexec/coldsync/todo-text 2004-07-24 20:20:40.000000000 -0400
+++ todo-text-2 2004-08-01 14:41:44.000000000 -0400
@@ -15,6 +15,8 @@
# XXX - When syncing a category whose name is empty, use #NNN, where NNN is
# the category ID.
+# added ability to deal with dates 2004/07/28 aneal
+
use strict;
use Palm::ToDo;
use ColdSync;
@@ -26,6 +28,8 @@
"Where" => "$ENV{HOME}/ToDo", # Directory to sync with
"Item-Prefix" => "- ", # Start of unfinished item
"Done-Prefix" => "* ", # Start of completed item
+ "Date-Start" => "(", # Start of Date Field
+ "Date-Stop" => ") ", # End of Date Field
"Item-Cont" => " ", # Continuation of item description
"Note-Indent" => " ", # Continuation of note
"Paragraph" => "\t", # Marks new paragraph in note
@@ -107,6 +111,13 @@
$record->{description} = $item->{title};
$record->{note} = $item->{note}
if $item->{note} ne "";
+ # Set due date if defined
+ if ($item->{due_day})
+ {
+ $record->{due_month} = $item->{due_month};
+ $record->{due_day} = $item->{due_day};
+ $record->{due_year} = $item->{due_year};
+ }
$record->{_seen} = 1;
# Mark this record as seen
} else {
@@ -127,9 +138,21 @@
$record->{attributes}{dirty} = 1;
}
+ # Here we update the due date if different
+ if ((defined($item->{due_day}) or defined($record->{due_day})) and
+ (($item->{due_day} ne $record->{due_day})
+ || ($item->{due_month} ne $record->{due_month})
+ || ($item->{due_year} ne $record->{due_year})))
+ {
+ $record->{due_month} = $item->{due_month};
+ $record->{due_day} = $item->{due_day};
+ $record->{due_year} = $item->{due_year};
+ $record->{attributes}{dirty} = 1;
+ }
+
# The description is the same, we know
# that. Also, we don't touch the record's
- # priority or due date.
+ # priority.
$priority = $record->{priority};
# Record this record's priority
@@ -215,6 +238,31 @@
$_ = $';
$intitle = 1;
}
+
+ # Date Processing
+ if (/^\Q$HEADERS{"Date-Start"}\E/)
+ {
+ # This todo item has a due date assigned
+ $_ = $';
+ # parse date
+ if (/^\d{1,2}\/\d{1,2}\/\d{2,4}/)
+ {
+ my $date = $&;
+ $_ = $';
+ my ($month, $day, $year) = split('/', $date);
+ $item->{due_month} = $month;
+ $item->{due_day} = $day;
+ $item->{due_year} = $year;
+ # day month year and date should go out of scope here
+ }
+ else {
+ warn "403 Date malformed :$_";
+ }
+ if (/^\Q$HEADERS{"Date-Stop"}\E/)
+ {
+ $_ = $';
+ }
+ }
# Common processing for all title lines.
if ($intitle)
@@ -362,6 +410,17 @@
print OUT $HEADERS{"Item-Prefix"};
}
+ # Due Date printing if it's set
+ if ($record->{due_day})
+ {
+ print OUT $HEADERS{"Date-Start"};
+ print OUT $record->{due_month} . '/';
+ print OUT $record->{due_day} . '/';
+ print OUT $record->{due_year};
+ print OUT $HEADERS{"Date-Stop"};
+ }
+
+
my $desc = $record->{description};
# There have to be two expressions here, to deal with
@@ -509,10 +568,6 @@
(aka "Bugs that I don't intend to fix".)
-C<todo-text> doesn't deal with due dates, mainly because I don't use them.
-If an existing item has a due date attached, C<todo-text> doesn't modify
-it, though.
-
C<todo-text> deals with priorities in the following way: when it is run as
a Dump conduit, it writes the to do list in order of decreasing priority
(I<i.e.>, priority 1 at the top, priority 5 at the bottom).
Attachment:
pgpZ7v8nIErJ8.pgp
Description: PGP signature