mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement - #390 timestamps in annotations
- added new dateformat for annotations - documented prev. added format modifiers H, N and S
This commit is contained in:
parent
2bfd220714
commit
70e6f4f9f6
7 changed files with 68 additions and 25 deletions
|
@ -10,6 +10,8 @@
|
|||
and 'ghistory' command as 'history.annual' and 'ghistory.annual'.
|
||||
+ Added feature #363 supporting iCalendar export via the 'export.ical'
|
||||
command.
|
||||
+ Added feature #390, an extra dateformat for annotations (thanks to Cory
|
||||
Donnelly).
|
||||
+ Fixed bug #406 so that task now includes command aliases in the _commands
|
||||
helper command used by shell completion scripts.
|
||||
+ Fixed bug #211 - it was unclear which commands modify a task description.
|
||||
|
|
|
@ -285,6 +285,8 @@ for example, or 'export'.
|
|||
.TP
|
||||
.B dateformat.holiday=YMD
|
||||
.TP
|
||||
.B dateformat.annotation=m/d/Y
|
||||
.TP
|
||||
.B report.X.dateformat=m/d/Y
|
||||
This is a string of characters that define how task formats date values. The
|
||||
precedence order for the configuration variable is report.X.dateformat then
|
||||
|
@ -319,6 +321,12 @@ b short name of month, for example Jan or Aug
|
|||
B long name of month, for example January or August
|
||||
.br
|
||||
V weeknumber, for example 03 or 37
|
||||
.br
|
||||
H two-digit hour, for example 03 or 11
|
||||
.br
|
||||
N two-digit minutes, for example 05 or 42
|
||||
.br
|
||||
S two-digit seconds, for example 07 or 47
|
||||
.RE
|
||||
.RE
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ std::string Config::defaults =
|
|||
"dateformat=m/d/Y # Preferred input and display date format\n"
|
||||
"dateformat.holiday=YMD # Preferred input date format for holidays\n"
|
||||
"dateformat.report=m/d/Y # Preferred display date format for repors\n"
|
||||
"dateformat.annotation=m/d/Y # Preferred display date format for repors\n"
|
||||
"weekstart=Sunday # Sunday or Monday only\n"
|
||||
"displayweeknumber=yes # Show week numbers on calendar\n"
|
||||
"due=7 # Task is considered due in 7 days\n"
|
||||
|
|
|
@ -738,7 +738,7 @@ int handleConfig (std::string &outs)
|
|||
"color.alternate color.calendar.today color.calendar.due color.calendar.due.today "
|
||||
"color.calendar.overdue color.calendar.weekend color.calendar.holiday "
|
||||
"color.calendar.weeknumber confirmation curses data.location dateformat "
|
||||
"dateformat.holiday dateformat.report debug default.command "
|
||||
"dateformat.holiday dateformat.report dateformat.annotation debug default.command "
|
||||
"default.priority default.project defaultwidth due locale "
|
||||
"displayweeknumber echo.command fontunderline locking monthsperline nag "
|
||||
"next project shadow.command shadow.file shadow.notify weekstart editor "
|
||||
|
|
|
@ -164,13 +164,12 @@ static std::string formatTask (Task task)
|
|||
foreach (anno, annotations)
|
||||
{
|
||||
Date dt (::atoi (anno->name ().substr (11).c_str ()));
|
||||
before << " Annotation: " << dt.toString (context.config.get ("dateformat"))
|
||||
before << " Annotation: " << dt.toString (context.config.get ("dateformat.annotation"))
|
||||
<< " " << anno->value () << std::endl;
|
||||
}
|
||||
|
||||
Date now;
|
||||
before << " Annotation: " << now.toString (context.config.get ("dateformat")) << " " << std::endl
|
||||
<< " Annotation: " << now.toString (context.config.get ("dateformat")) << " " << std::endl
|
||||
before << " Annotation: " << now.toString (context.config.get ("dateformat.annotation")) << " " << std::endl
|
||||
<< "# End" << std::endl;
|
||||
|
||||
return before.str ();
|
||||
|
@ -503,7 +502,7 @@ static void parseTask (Task& task, const std::string& after)
|
|||
std::string::size_type gap = value.find (" ");
|
||||
if (gap != std::string::npos)
|
||||
{
|
||||
Date when (value.substr (0, gap), context.config.get ("dateformat"));
|
||||
Date when (value.substr (0, gap), context.config.get ("dateformat.annotation"));
|
||||
|
||||
// This guarantees that if more than one annotation has the same date,
|
||||
// that the seconds will be different, thus unique, thus not squashed.
|
||||
|
|
|
@ -2763,7 +2763,10 @@ std::string getFullDescription (Task& task, const std::string& report)
|
|||
foreach (anno, annotations)
|
||||
{
|
||||
Date dt (atoi (anno->name ().substr (11).c_str ()));
|
||||
std::string when = dt.toString (context.config.get ("dateformat"));
|
||||
std::string format = context.config.get ("dateformat.annotation");
|
||||
if (format == "")
|
||||
format = context.config.get ("dateformat");
|
||||
std::string when = dt.toString (format);
|
||||
desc += "\n" + when + " " + anno->value ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 37;
|
||||
use Test::More tests => 50;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'annotate.rc')
|
||||
|
@ -77,16 +77,17 @@ my $output = qx{../task rc:annotate.rc rrr};
|
|||
# 4 four
|
||||
#
|
||||
# 4 tasks
|
||||
|
||||
like ($output, qr/1 one/, 'task 1');
|
||||
like ($output, qr/2 two/, 'task 2');
|
||||
like ($output, qr/3 three/, 'task 3');
|
||||
like ($output, qr/4 four/, 'task 4');
|
||||
like ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo1/ms, 'first annotation task 1');
|
||||
like ($output, qr/foo1.+\d{1,2}\/\d{1,2}\/\d{4} foo2/ms, 'second annotation task 1');
|
||||
like ($output, qr/foo2.+\d{1,2}\/\d{1,2}\/\d{4} foo3/ms, 'third annotation task 1');
|
||||
like ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar1/ms, 'first annotation task 2');
|
||||
like ($output, qr/bar1.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'second annotation task 2');
|
||||
like ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms,'first annotation task 3');
|
||||
like ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo1/ms, 'full - first annotation task 1');
|
||||
like ($output, qr/foo1.+\d{1,2}\/\d{1,2}\/\d{4} foo2/ms, 'full - second annotation task 1');
|
||||
like ($output, qr/foo2.+\d{1,2}\/\d{1,2}\/\d{4} foo3/ms, 'full - third annotation task 1');
|
||||
like ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar1/ms, 'full - first annotation task 2');
|
||||
like ($output, qr/bar1.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'full - second annotation task 2');
|
||||
like ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms,'full - first annotation task 3');
|
||||
like ($output, qr/4 tasks/, 'count');
|
||||
|
||||
$output = qx{../task rc:annotate.rc rc.annotations:sparse rrr};
|
||||
|
@ -94,12 +95,12 @@ like ($output, qr/1 \+one/, 'task 1');
|
|||
like ($output, qr/2 \+two/, 'task 2');
|
||||
like ($output, qr/3 three/, 'task 3');
|
||||
like ($output, qr/4 four/, 'task 4');
|
||||
unlike ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo1/ms, 'first annotation task 1');
|
||||
unlike ($output, qr/foo1.+\d{1,2}\/\d{1,2}\/\d{4} foo2/ms, 'second annotation task 1');
|
||||
like ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo3/ms, 'third annotation task 1');
|
||||
unlike ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar1/ms, 'first annotation task 2');
|
||||
like ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'second annotation task 2');
|
||||
like ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms, 'third annotation task 3');
|
||||
unlike ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo1/ms, 'sparse - first annotation task 1');
|
||||
unlike ($output, qr/foo1.+\d{1,2}\/\d{1,2}\/\d{4} foo2/ms, 'sparse - second annotation task 1');
|
||||
like ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo3/ms, 'sparse - third annotation task 1');
|
||||
unlike ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar1/ms, 'sparse - first annotation task 2');
|
||||
like ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'sparse - second annotation task 2');
|
||||
like ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms, 'sparse - third annotation task 3');
|
||||
like ($output, qr/4 tasks/, 'count');
|
||||
|
||||
$output = qx{../task rc:annotate.rc rc.annotations:none rrr};
|
||||
|
@ -107,12 +108,39 @@ like ($output, qr/1 \+one/, 'task 1');
|
|||
like ($output, qr/2 \+two/, 'task 2');
|
||||
like ($output, qr/3 \+three/, 'task 3');
|
||||
like ($output, qr/4 four/, 'task 4');
|
||||
unlike ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo1/ms, 'first annotation task 1');
|
||||
unlike ($output, qr/foo1.+\d{1,2}\/\d{1,2}\/\d{4} foo2/ms, 'second annotation task 1');
|
||||
unlike ($output, qr/foo2.+\d{1,2}\/\d{1,2}\/\d{4} foo3/ms, 'third annotation task 1');
|
||||
unlike ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar1/ms, 'first annotation task 2');
|
||||
unlike ($output, qr/bar1.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'second annotation task 2');
|
||||
unlike ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms, 'third annotation task 3');
|
||||
unlike ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo1/ms, 'none - first annotation task 1');
|
||||
unlike ($output, qr/foo1.+\d{1,2}\/\d{1,2}\/\d{4} foo2/ms, 'none - second annotation task 1');
|
||||
unlike ($output, qr/foo2.+\d{1,2}\/\d{1,2}\/\d{4} foo3/ms, 'none - third annotation task 1');
|
||||
unlike ($output, qr/two.+\d{1,2}\/\d{1,2}\/\d{4} bar1/ms, 'none - first annotation task 2');
|
||||
unlike ($output, qr/bar1.+\d{1,2}\/\d{1,2}\/\d{4} bar2/ms, 'none - second annotation task 2');
|
||||
unlike ($output, qr/three.+\d{1,2}\/\d{1,2}\/\d{4} baz1/ms, 'none - third annotation task 3');
|
||||
like ($output, qr/4 tasks/, 'count');
|
||||
|
||||
if (open my $fh, '>', 'annotate2.rc')
|
||||
{
|
||||
# Note: Use 'rrr' to guarantee a unique report name. Using 'r' conflicts
|
||||
# with 'recurring'.
|
||||
print $fh "data.location=.\n",
|
||||
"confirmation=off\n",
|
||||
"report.rrr.description=rrr\n",
|
||||
"report.rrr.columns=id,description\n",
|
||||
"report.rrr.sort=id+\n",
|
||||
"dateformat.annotation=yMD HNS\n";
|
||||
close $fh;
|
||||
ok (-r 'annotate2.rc', 'Created annotate2.rc');
|
||||
}
|
||||
|
||||
$output = qx{../task rc:annotate2.rc rrr};
|
||||
like ($output, qr/1 one/, 'task 1');
|
||||
like ($output, qr/2 two/, 'task 2');
|
||||
like ($output, qr/3 three/, 'task 3');
|
||||
like ($output, qr/4 four/, 'task 4');
|
||||
like ($output, qr/one.+\d{1,6} \d{1,6} foo1/ms, 'dateformat - first annotation task 1');
|
||||
like ($output, qr/foo1.+\d{1,6} \d{1,6} foo2/ms, 'dateformat - second annotation task 1');
|
||||
like ($output, qr/foo2.+\d{1,6} \d{1,6} foo3/ms, 'dateformat - third annotation task 1');
|
||||
like ($output, qr/two.+\d{1,6} \d{1,6} bar1/ms, 'dateformat - first annotation task 2');
|
||||
like ($output, qr/bar1.+\d{1,6} \d{1,6} bar2/ms, 'dateformat - second annotation task 2');
|
||||
like ($output, qr/three.+\d{1,6} \d{1,6} baz1/ms,'dateformat - first annotation task 3');
|
||||
like ($output, qr/4 tasks/, 'count');
|
||||
|
||||
# Cleanup.
|
||||
|
@ -124,6 +152,8 @@ ok (!-r 'undo.data', 'Removed undo.data');
|
|||
|
||||
unlink 'annotate.rc';
|
||||
ok (!-r 'annotate.rc', 'Removed annotate.rc');
|
||||
unlink 'annotate2.rc';
|
||||
ok (!-r 'annotatei2.rc', 'Removed annotate2.rc');
|
||||
|
||||
exit 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue