- added a calendar offset that effectively changes the first
  month to be displayed in the calendar report (thanks to
  Michelle Crane)
- calendar.offset turns the featue off or on
- calendar.offset.value controls the number of month to be
  applied for the offset
This commit is contained in:
Federico Hernandez 2010-12-01 23:25:13 +01:00
parent 14ab7ba7bd
commit 4ca35fb956
7 changed files with 61 additions and 6 deletions

View file

@ -19,6 +19,8 @@
to a file, by setting defaultwidth to 0.
+ Added feature #546, which is a 'count' command that counts tasks, and is
intended to help scripts that manipulate task output.
+ Added feature #567, which makes it possible to apply an offset to the first
month to be displayed in the calendar report (thanks to Michelle Crane)
+ Fixed bug #515, which displayed an incorrect message after duplicating a
non-existent task (thanks to Peter De Poorter).
+ Fixed bug #529, where the 'depends' attribute was not mentioned in the

6
NEWS
View file

@ -8,6 +8,8 @@ New Features in taskwarrior 1.9.4
- Added highlighting for the show command that indicates which values differ
from the defaults.
- Added change log display to the 'info' command.
- The first month in the calendar report can now be changed with an offset
value.
Please refer to the ChangeLog file for full details. There are too many to
list here.
@ -34,6 +36,8 @@ New configuration options in taskwarrior 1.9.4
the 'info' command.
- gc=off can be used, temporarily, to defer GC until later commands, which
eliminates problems with task ID numbers for script writers.
- calendar.offset=off and calendar.offset.value=-1 to apply an offset value
to change the effective first month in the calendar report.
Newly deprecated features in taskwarrior 1.9.4
@ -44,7 +48,7 @@ Newly deprecated features in taskwarrior 1.9.4
Taskwarrior has been built and tested on the following configurations:
* OS X 10.6 Snow Leopard and 10.5 Leopard
* Fedora 13 Goddard, 12 Constantine
* Fedora 14 Laughlin, 13 Goddard
* Ubuntu 10.10 Maverick Meerkat, 10.04 Lucid Lynx
* Debian Sid
* Slackware 12.2

View file

@ -467,6 +467,16 @@ is "sparse".
The report to run when displaying the details of tasks with due date when
running the "task calendar" command. The default value is "list".
.TP
.B calendar.offset=off
If "on" the first month in the calendar report is effectively changed by the
offset value specified in calendar.offset.value. It defaults to "off".
.TP
.B calendar.offset.value=-1
The offset value to apply to the first month in the calendar report. The default
value is "-1".
.TP
.B calendar.holidays=full
If set to full running "task calendar" will display holidays in the calendar by

View file

@ -97,6 +97,8 @@ std::string Config::defaults =
"calendar.legend=yes # Display the legend on calendar\n"
"calendar.details=sparse # Calendar shows information for tasks w/due dates: full, sparse or none\n"
"calendar.details.report=list # Report to use when showing task information in cal\n"
"calendar.offset=no # Apply an offset value to control the first month of the calendar\n"
"calendar.offset.value=-1 # The number of months the first month of the calendar is moved\n"
"calendar.holidays=none # Show public holidays on calendar:full, sparse or none\n"
"#monthsperline=3 # Number of calendar months on a line\n"
"\n"

View file

@ -891,8 +891,8 @@ int handleShow (std::string& outs)
// Note that there is a leading and trailing space, to make it easier to
// search for whole words.
std::string recognized =
" annotations blanklines bulk burndown.bias calendar.details "
"calendar.details.report calendar.holidays calendar.legend color "
" annotations blanklines bulk burndown.bias calendar.details calendar.details.report "
"calendar.holidays calendar.legend color calendar.offset calendar.offset.value "
"color.active color.due color.due.today color.blocked color.burndown.done "
"color.burndown.pending color.burndown.started color.overdue color.pri.H "
"color.pri.L color.pri.M color.pri.none color.recurring color.tagged "

View file

@ -1477,10 +1477,29 @@ int handleReportCalendar (std::string& outs)
yFrom = oldest.year();
}
if (context.config.getBoolean ("calendar.offset"))
{
int moffset = context.config.getInteger ("calendar.offset.value") % 12;
int yoffset = context.config.getInteger ("calendar.offset.value") / 12;
mFrom += moffset;
yFrom += yoffset;
if (mFrom < 1)
{
mFrom += 12;
yFrom--;
}
else if (mFrom > 12)
{
mFrom -= 12;
yFrom++;
}
}
mTo = mFrom + monthsToDisplay - 1;
yTo = yFrom;
if (mTo > 12) {
mTo -=12;
if (mTo > 12)
{
mTo -= 12;
yTo++;
}

View file

@ -30,7 +30,7 @@
use strict;
use warnings;
use Test::More tests => 76;
use Test::More tests => 87;
# Create the rc file.
if (open my $fh, '>', 'cal.rc')
@ -54,6 +54,7 @@ my $day = $nday;
my $prevmonth = $months[($nmon-1) % 12];
my $month = $months[($nmon) % 12];
my $nextmonth = $months[($nmon+1) % 12];
my $prevyear = $nyear + 1899;
my $year = $nyear + 1900;
my $nextyear = $nyear + 1901;
@ -137,6 +138,23 @@ unlike ($output, qr/March 2010/, 'March 2010 is not displayed');
like ($output, qr/April 2010/, 'April 2010 is displayed');
unlike ($output, qr/May 2010/, 'May 2010 is not displayed');
# calendar offsets
$output = qx{../task rc:cal.rc rc.calendar.offset:on rc.monthsperline:1 cal 1 2011};
unlike ($output, qr/November 2010/, 'November 2010 is not displayed');
like ($output, qr/December 2010/, 'December 2010 is displayed');
unlike ($output, qr/January 2011/, 'January 2011 is not displayed');
$output = qx{../task rc:cal.rc rc.calendar.offset:on rc.calendar.offset.value:2 rc.monthsperline:1 cal 1 2011};
unlike ($output, qr/January 2011/, 'January 2011 is not displayed');
unlike ($output, qr/February 2011/, 'February 2011 is not displayed');
like ($output, qr/March 2011/, 'March 2011 is displayed');
unlike ($output, qr/April 2011/, 'April 2011 is not displayed');
$output = qx{../task rc:cal.rc rc.calendar.offset:on rc.calendar.offset.value:-12 rc.monthsperline:1 cal};
like ($output, qr/$month\S*?\s+?$prevyear/, 'Current month and year ahead are displayed');
unlike ($output, qr/$month\S*?\s+?$year/, 'Current month and year are not displayed');
$output = qx{../task rc:cal.rc rc.calendar.offset:on rc.calendar.offset.value:12 rc.monthsperline:1 cal};
unlike ($output, qr/$month\S*?\s+?$year/, 'Current month and year are not displayed');
like ($output, qr/$month\S*?\s+?$nextyear/, 'Current month and year ahead are displayed');
# Cleanup.
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data');