Enhancement

- Clarify the dateformat related variables for 'task information'.
This commit is contained in:
Louis-Claude Canon
2012-05-16 14:42:11 +02:00
committed by Paul Beckingham
parent 84e1d0e7d2
commit ba992a631e
7 changed files with 20 additions and 21 deletions

View File

@@ -475,15 +475,16 @@ Enables the extension system. Defaults to on.
.TP .TP
.B dateformat.holiday=YMD .B dateformat.holiday=YMD
.TP .TP
.B dateformat.info=m/d/Y H:N:S
.TP
.B dateformat.annotation=m/d/Y .B dateformat.annotation=m/d/Y
.TP .TP
.B report.X.dateformat=m/d/Y .B report.X.dateformat=m/d/Y
This is a string of characters that define how taskwarrior formats date values. This is a string of characters that define how taskwarrior formats date values.
The precedence order for the configuration variable is report.X.dateformat then The precedence order for the configuration variable is report.X.dateformat then
dateformat.report then dateformat. While report.X.dateformat only formats the dateformat.report then dateformat for formating the due dates in reports.
due date in reports, report.info.dateformat formats all the displayed dates of If both report.X.dateformat and dateformat.report are not set then dateformat
"task info". dateformat.report formats the date both in reports will be applied
and "task info". If both of these are not set then dateformat will be applied
to the date. Entered dates as well as all other displayed dates in reports to the date. Entered dates as well as all other displayed dates in reports
are formatted according to dateformat. are formatted according to dateformat.

View File

@@ -109,6 +109,7 @@ std::string Config::_defaults =
"# Dates\n" "# Dates\n"
"dateformat=m/d/Y # Preferred input and display date format\n" "dateformat=m/d/Y # Preferred input and display date format\n"
"dateformat.holiday=YMD # Preferred input date format for holidays\n" "dateformat.holiday=YMD # Preferred input date format for holidays\n"
"dateformat.info=m/d/Y H:N:S # Preferred display date format for information\n"
"dateformat.report=m/d/Y # Preferred display date format for reports\n" "dateformat.report=m/d/Y # Preferred display date format for reports\n"
"dateformat.annotation=m/d/Y # Preferred display date format for annotations\n" "dateformat.annotation=m/d/Y # Preferred display date format for annotations\n"
"weekstart=Sunday # Sunday or Monday only\n" "weekstart=Sunday # Sunday or Monday only\n"

View File

@@ -76,12 +76,9 @@ int CmdInfo::execute (std::string& output)
undo = context.tdb2.undo.get_lines (); undo = context.tdb2.undo.get_lines ();
// Determine the output date format, which uses a hierarchy of definitions. // Determine the output date format, which uses a hierarchy of definitions.
// rc.report.<report>.dateformat // rc.dateformat.info
// rc.dateformat.report // rc.dateformat
// rc.dateformat. std::string dateformat = context.config.get ("dateformat.info");
std::string dateformat = context.config.get ("report.info.dateformat");
if (dateformat == "")
dateformat = context.config.get ("dateformat.report");
if (dateformat == "") if (dateformat == "")
dateformat = context.config.get ("dateformat"); dateformat = context.config.get ("dateformat");

View File

@@ -129,6 +129,7 @@ int CmdShow::execute (std::string& output)
" dateformat" " dateformat"
" dateformat.annotation" " dateformat.annotation"
" dateformat.holiday" " dateformat.holiday"
" dateformat.info"
" dateformat.report" " dateformat.report"
" debug" " debug"
" default.command" " default.command"

View File

@@ -28,7 +28,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 6; use Test::More tests => 5;
# Create the rc file. # Create the rc file.
if (open my $fh, '>', 'bug.rc') if (open my $fh, '>', 'bug.rc')
@@ -47,18 +47,14 @@ if (open my $fh, '>', 'bug.rc')
qx{../src/task rc:bug.rc add test}; qx{../src/task rc:bug.rc add test};
qx{../src/task rc:bug.rc test start}; qx{../src/task rc:bug.rc test start};
# Test that report.info.dateformat has precedence over dateformat.report and # Test that dateformat.info has precedence over dateformat and that no other
# dateformat and that no other format is applied # format is applied
my $output = qx{../src/task rc:bug.rc test info rc.dateformat:m/d/Y rc.dateformat.report:m/d/Y rc.report.info.dateformat:__}; my $output = qx{../src/task rc:bug.rc test info rc.dateformat:m/d/Y rc.dateformat.info:__};
like ($output, qr/__/ms, 'Date formatted according to report.info.dateformat'); like ($output, qr/__/ms, 'Date formatted according to dateformat.info');
unlike ($output, qr/[0-9]*\/[0-9]*\/20[0-9]*/ms, 'No date is incorrectly formatted'); unlike ($output, qr/[0-9]*\/[0-9]*\/20[0-9]*/ms, 'No date is incorrectly formatted');
# Similar for dateformat.report (no need to check that another format is applied again)
$output = qx{../src/task rc:bug.rc test info rc.dateformat:m/d/Y rc.dateformat.report:__ rc.report.info.dateformat:};
like ($output, qr/__/ms, 'Date formatted according to dateformat.report');
# Similar for dateformat # Similar for dateformat
$output = qx{../src/task rc:bug.rc test info rc.dateformat:__ rc.dateformat.report: rc.report.info.dateformat:}; $output = qx{../src/task rc:bug.rc test info rc.dateformat:__ rc.dateformat.info:};
like ($output, qr/__/ms, 'Date formatted according to dateformat'); like ($output, qr/__/ms, 'Date formatted according to dateformat');
### Cleanup. ### Cleanup.

View File

@@ -35,6 +35,7 @@ if (open my $fh, '>', 'date1.rc')
{ {
print $fh "data.location=.\n", print $fh "data.location=.\n",
"dateformat=YMD\n", "dateformat=YMD\n",
"dateformat.info=YMD\n",
"dateformat.report=YMD\n"; "dateformat.report=YMD\n";
close $fh; close $fh;
ok (-r 'date1.rc', 'Created date1.rc'); ok (-r 'date1.rc', 'Created date1.rc');
@@ -44,6 +45,7 @@ if (open my $fh, '>', 'date2.rc')
{ {
print $fh "data.location=.\n", print $fh "data.location=.\n",
"dateformat=m/d/y\n", "dateformat=m/d/y\n",
"dateformat.info=m/d/y\n",
"dateformat.report=m/d/y\n"; "dateformat.report=m/d/y\n";
close $fh; close $fh;
ok (-r 'date2.rc', 'Created date2.rc'); ok (-r 'date2.rc', 'Created date2.rc');
@@ -55,6 +57,7 @@ if (open my $fh, '>', 'date3.rc')
"dateformat=m/d/y\n", "dateformat=m/d/y\n",
"dateformat=m/d/y\n", "dateformat=m/d/y\n",
"weekstart=Monday\n", "weekstart=Monday\n",
"dateformat.info=A D B Y (vV)\n",
"dateformat.report=A D B Y (vV)\n"; "dateformat.report=A D B Y (vV)\n";
close $fh; close $fh;
ok (-r 'date3.rc', 'Created date3.rc'); ok (-r 'date3.rc', 'Created date3.rc');

View File

@@ -35,7 +35,7 @@ if (open my $fh, '>', 'dom.rc')
{ {
print $fh "data.location=.\n", print $fh "data.location=.\n",
"dateformat=YMD\n", "dateformat=YMD\n",
"report.info.dateformat=YMD\n"; "dateformat.info=YMD\n";
close $fh; close $fh;
ok (-r 'dom.rc', 'Created dom.rc'); ok (-r 'dom.rc', 'Created dom.rc');
} }