diff --git a/src/report.cpp b/src/report.cpp index f0df5b16d..3fe91d6bd 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -1489,19 +1489,19 @@ int handleReportCalendar (std::string &outs) int monthsToDisplay = 1; int mFrom = today.month (); int yFrom = today.year (); - int mTo; - int yTo; + int mTo = mFrom; + int yTo = yFrom; // Determine what to do int numberOfArgs = context.args.size(); - if (numberOfArgs == 1 ) { + if (numberOfArgs == 1) { // task cal monthsToDisplay = monthsPerLine; mFrom = today.month(); yFrom = today.year(); } - else if (numberOfArgs == 2 ) { + else if (numberOfArgs == 2) { if (context.args[1] == "y") { // task cal y monthsToDisplay = 12; @@ -1520,7 +1520,7 @@ int handleReportCalendar (std::string &outs) yFrom = atoi( context.args[1].data()); } } - else if (numberOfArgs == 3 ) { + else if (numberOfArgs == 3) { if (context.args[2] == "y") { // task cal due y monthsToDisplay = 12; @@ -1533,7 +1533,7 @@ int handleReportCalendar (std::string &outs) yFrom = atoi( context.args[2].data()); } } - else if (numberOfArgs == 4 ) { + else if (numberOfArgs == 4) { // task cal 8 2010 y monthsToDisplay = 12; mFrom = atoi( context.args[1].data()); @@ -1560,11 +1560,6 @@ int handleReportCalendar (std::string &outs) yFrom = oldest.year(); } - // If there are no tasks with due dates, then prevent showing a calendar from - // the year 2037. - if (countDueDates == 0) - throw std::string ("There are no tasks that have due dates."); - mTo = mFrom + monthsToDisplay - 1; yTo = yFrom; if (mTo > 12) { diff --git a/src/tests/cal.t b/src/tests/cal.t index 3b22cdd35..fe354543a 100755 --- a/src/tests/cal.t +++ b/src/tests/cal.t @@ -2,7 +2,7 @@ ################################################################################ ## task - a command line task list manager. ## -## Copyright 2006 - 2009, Paul Beckingham. +## Copyright 2006 - 2009, Paul Beckingham, Federico Hernandez. ## All rights reserved. ## ## Unit test cal.t originally writen by Federico Hernandez @@ -42,11 +42,11 @@ if (open my $fh, '>', 'cal.rc') close $fh; ok (-r 'cal.rc', 'Created cal.rc'); } - +my @months = qw(Jan Fev Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my ($day, $nmon, $nyear) = (localtime)[3,4,5]; -my $nextmonth = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon+1) % 12]; -my $month = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon) % 12]; -my $prevmonth = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[($nmon-1) % 12]; +my $nextmonth = $months[($nmon+1) % 12]; +my $month = $months[($nmon) % 12]; +my $prevmonth = $months[($nmon-1) % 12]; my $nextyear = $nyear + 1901; my $year = $nyear + 1900; @@ -59,7 +59,7 @@ if ( $day <= 9) my $output = qx{../task rc:cal.rc rc._forcecolor:on cal}; like ($output, qr/\[36m$day/, 'Current day is highlighted'); like ($output, qr/$month\w+?\s+?$year/, 'Current month and year are displayed'); -qx{../task rc:cal.rc add zero}; +$output = qx{../task rc:cal.rc add zero}; unlike ($output, qr/\[41m\d+/, 'No overdue tasks are present'); unlike ($output, qr/\[43m\d+/, 'No due tasks are present'); $output = qx{../task rc:cal.rc rc.weekstart:Sunday cal};