summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2012-05-25 08:17:09 +0200
committercos <cos>2012-12-17 21:12:07 +0100
commitce997e6136f96c52dd869cedce63ca412eaa2367 (patch)
tree65b9903f255260f6ce4923100cee9288b31a8af6
parent299c3b127fb36820244fde8a1008d0685d26898e (diff)
downloadmat-ce997e6136f96c52dd869cedce63ca412eaa2367.zip
Make showplan show four weeks separated with blank lines.
-rwxr-xr-xmat11
1 files changed, 10 insertions, 1 deletions
diff --git a/mat b/mat
index c9471fc..a3f3348 100755
--- a/mat
+++ b/mat
@@ -224,6 +224,7 @@ sub get_plan_state {
sub cmd_showplan {
my ( $date ) = @_;
my $dt;
+ my $weekend_padding = "";
if($date) {
return -1 unless $date =~ "^[0-9]{4}-[0-9]{2}-[0-9]{2}\$";
@@ -233,17 +234,25 @@ sub cmd_showplan {
# FIXME now() is not start of day, set hour, minute and such to 0
}
- for (my $i = 0; $i < 7; $i++) {
+ for (my $i = 0; $i < 28; $i++) {
my $sql = "SELECT recipe_id, mealtype FROM plan WHERE date='".$dt->ymd().
"';";
my @ids = $db->selectrow_array($sql);
+ print $weekend_padding;
if ($ids[0]) {
printf "%9s %-10s %3s|%s %s, %s\n", $dt->ymd(), $ids[1], $ids[0],
substr(get_plan_state($dt->ymd()), 0, 1), get_recipe_name($ids[0]),
get_recipe_uri($ids[0]);
+ } else {
+ printf "%-24s | \n", $dt->ymd();
}
$dt->add(days => 1);
+ if($dt->day_of_week == 1) {
+ $weekend_padding = "\n";
+ } else {
+ $weekend_padding = "";
+ }
}
}