Dotfiles, utilities, and other apparatus.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

63 lines
1.3 KiB

#!/usr/bin/env perl
=pod
=head1 NAME
notes-calendar - show calendar entries for a given date, in context of my notes
=head1 SYNOPSIS
# Show calendar entries for 2021-11-21
notes calendar 2021-11-21
=head1 AUTHOR
Brennen Bearnes
=cut
use warnings;
use strict;
use 5.10.0;
use Cwd;
use Data::Dumper;
use DBI;
use File::Basename;
use File::Spec;
use Getopt::Long;
use Pod::Usage;
use SQL::Abstract;
use Sys::Hostname;
# Handle options, including help generated from the POD above.
my $debug = 0;
GetOptions(
'debug' => \$debug,
'help' => sub { pod2usage(0) },
) or pod2usage(2);
my ($date) = $ARGV[0];
unless (defined $date) {
die "Must specify a date";
}
my $date_for_calendar = $date;
$date_for_calendar =~ s/-//g;
# -t "$date_for_calendar": treat $date_for_calendar as today
# -B 2 -A 0: show last 2 days of entries for context
# -A 14: show next 2 weeks of entries
# -w: show name of weekday
# TODO: Figure out how to get this without the redundancy:
# my $before_today_output = `cd ~/notes && calendar -t "$date_for_calendar" -B 2 -A 0 -w`;
# my $after_today_output = `cd ~/notes && calendar -t "$date_for_calendar" -A 14 -w`;
# print "${before_today_output}/********/\n$after_today_output";
my $calendar_output = `cd ~/notes && calendar -t "$date_for_calendar" -A 14 -B 2 -w`;
print $calendar_output;
1;