aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-11-22 19:13:24 +0000
committerMatthew Lemon <lemon@matthewlemon.com>2020-11-22 19:13:24 +0000
commit12551ffb5724074c4de53a6275659e0efbc06359 (patch)
treebc3f532531e25e35283fe2fb6497c920caba10d8
parent7cae84104ae6670d68e87887dc28d01c9ecaee94 (diff)
progress
-rw-r--r--tw_hooks/on-add_schedule_tg.pl10
-rw-r--r--tw_hooks/scratch.pl45
2 files changed, 55 insertions, 0 deletions
diff --git a/tw_hooks/on-add_schedule_tg.pl b/tw_hooks/on-add_schedule_tg.pl
index 085c8f9..5423180 100644
--- a/tw_hooks/on-add_schedule_tg.pl
+++ b/tw_hooks/on-add_schedule_tg.pl
@@ -9,6 +9,16 @@ use DateTime::Format::ISO8601;
# a test hook in Perl for taskwarrior
+
+# ALGORITHM
+
+# Parse the due attribute from TW
+# Convert it into Remind format
+# Log into remote server
+# Check for presece or remind file
+# If it is there, back it up
+# Append the Remind formatted line to the original remind file
+
my @short_months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my @days_of_week = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
diff --git a/tw_hooks/scratch.pl b/tw_hooks/scratch.pl
new file mode 100644
index 0000000..bbb0a91
--- /dev/null
+++ b/tw_hooks/scratch.pl
@@ -0,0 +1,45 @@
+use warnings;
+use strict;
+use feature qw(say);
+use JSON;
+use DateTime;
+use DateTime::Format::ISO8601;
+
+
+my @short_months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
+
+# subs
+sub parse_scheduled
+{
+ my $sched_date = shift;
+ return DateTime::Format::ISO8601->parse_datetime($sched_date);
+}
+
+# ALGORITHM
+# Parse the scheduled attribute from TW
+
+my $added_task = <STDIN>;
+my $decoded_task = decode_json $added_task;
+my $original_description = ${$decoded_task}{description};
+my $tags = ${$decoded_task}{tags}; # alternative - not using -> in the ref
+my $scheduled_dt;
+
+if ($decoded_task->{scheduled} and (scalar grep {$_ eq "dft" } @{$tags})) {
+ $scheduled_dt = parse_scheduled $decoded_task->{scheduled};
+ my $date = $scheduled_dt->day();
+ my $month = $short_months[$scheduled_dt->month()-1];
+ my $year = $scheduled_dt->year();
+ # Convert it into Remind format
+ my $remind_line = "REM $date $month $year AT 10:00 $original_description";
+ print $remind_line;
+} else {
+ print encode_json $decoded_task;
+}
+
+
+# Log into remote server
+# Check for presece or remind file
+# If it is there, back it up
+# Append the Remind formatted line to the original remind file
+
+