1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# Porting dayplan.ksh to Perl
use strict;
use warnings;
use DateTime;
my $numargs = $#ARGV + 1;
my $fp = "/tmp";
my ($dt, $d, $y, $m, $weekday);
my @weekdays = qw(Monday Tuesday Wednesday Thursday Friday Saturday Sunday);
if ($numargs == 1) {
($y, $m, $d) = $ARGV[0] =~ /(\d\d\d\d)-(\d\d)-(\d\d)/;
$dt = DateTime->new(
year => $y,
month => $m,
day => $d
);
$weekday = $weekdays[$dt->day_of_week - 1];
}
else {
$dt = DateTime->now;
$d = $dt->day;
$m = $dt->month;
$y = $dt->year;
$weekday = $weekdays[$dt->day_of_week - 1];
}
sub schoollines {
my $day = shift;
print "In schoolines\n";
if ($day =~ /Saturday|Sunday/) {
return "";
} else
{
return "
08:15 - 08:20 - Harvey to school
08:45 - 09:00 - Sophie to school
09:15 - 09:30 - Email";
}
}
my $reminders = qx(ssh bobbins remind ~/.reminders $y-$m-$d);
$reminders =~ s/\s{2,}/\n/gs;
$reminders =~ s/^Reminders.+\:\n//;
my $s = schoollines($weekday);
my $template = "Goal for $weekday: [replace this with your goal]
---
Reminders:
---------
$reminders
$s
09:30 - 10:00 -
10:00 - 11:00 -
11:00 - 12:00 -
12:15 - 13:00 - Lunch
13:00 - 14:00 -
14:00 - 15:00 -
15:00 - 16:00 -
16:00 - 17:00 -
";
my $today_planner = sprintf("%s/%d-%02d-%02d.txt", $fp,$y,$m,$d);
if (-e $today_planner) {
exec("vim", "$today_planner");
} else
{
open( FH, ">$today_planner");
print FH $template;
close FH;
exec("vim", "$today_planner");
}
|