aboutsummaryrefslogtreecommitdiffstats
path: root/tw_hooks/on-add_schedule_tg.pl
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@matthewlemon.com>2020-11-18 16:33:27 +0000
committerMatthew Lemon <lemon@matthewlemon.com>2020-11-18 16:33:27 +0000
commit8b4236d9919cb475600657abbd5294ea337e9ee2 (patch)
tree60383aff6119df369f1822c2a6a01d88f7e5ef61 /tw_hooks/on-add_schedule_tg.pl
parent4d2ca81a296adefdbae4ce7d81331f2a177887cb (diff)
added more nice date code
Diffstat (limited to 'tw_hooks/on-add_schedule_tg.pl')
-rw-r--r--tw_hooks/on-add_schedule_tg.pl16
1 files changed, 13 insertions, 3 deletions
diff --git a/tw_hooks/on-add_schedule_tg.pl b/tw_hooks/on-add_schedule_tg.pl
index a0690f5..085c8f9 100644
--- a/tw_hooks/on-add_schedule_tg.pl
+++ b/tw_hooks/on-add_schedule_tg.pl
@@ -9,6 +9,9 @@ use DateTime::Format::ISO8601;
# a test hook in Perl for taskwarrior
+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);
+
# this must be JSON - this gets passed in my taskwarrior
my $added_task = <STDIN>;
@@ -24,9 +27,16 @@ if ($hashref->{scheduled}) {
my $scheduled_dt = parse_scheduled $hashref->{scheduled};
print "Scheduled Date:\n";
print "---------------\n";
- print "Year is: ".$scheduled_dt->year . "\n";
- print "Month is: ".$scheduled_dt->month . "\n";
- print "Day is: ".$scheduled_dt->day . "\n";
+ print "Year is: ".$scheduled_dt->year() . "\n";
+ print "Month is: ".$scheduled_dt->month() . "\n";
+ print "Month again is: ".$short_months[$scheduled_dt->month()-1] . "\n";
+ print "Day is: ".$scheduled_dt->day() . "\n";
+ # O
+ # # wday() is builtin?
+ # https://stackoverflow.com/questions/10919585/extract-day-of-week-using-perl-and-mysql-date-format
+ # https://metacpan.org/pod/Time::Piece
+ print "Day of week is: ".$days_of_week[$scheduled_dt->day_of_week() % 7] . "\n";
+ print "Quarter is: ".$scheduled_dt->quarter(). "\n";
print "\n";
}