mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 09:53:08 +02:00
Enhancement
- Clarify the dateformat related variables for 'task information'.
This commit is contained in:
parent
84e1d0e7d2
commit
ba992a631e
7 changed files with 20 additions and 21 deletions
|
@ -475,15 +475,16 @@ Enables the extension system. Defaults to on.
|
|||
.TP
|
||||
.B dateformat.holiday=YMD
|
||||
.TP
|
||||
.B dateformat.info=m/d/Y H:N:S
|
||||
.TP
|
||||
.B dateformat.annotation=m/d/Y
|
||||
.TP
|
||||
.B report.X.dateformat=m/d/Y
|
||||
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
|
||||
dateformat.report then dateformat. While report.X.dateformat only formats the
|
||||
due date in reports, report.info.dateformat formats all the displayed dates of
|
||||
"task info". dateformat.report formats the date both in reports
|
||||
and "task info". If both of these are not set then dateformat will be applied
|
||||
dateformat.report then dateformat for formating the due dates in reports.
|
||||
If both report.X.dateformat and dateformat.report are not set then dateformat
|
||||
will be applied
|
||||
to the date. Entered dates as well as all other displayed dates in reports
|
||||
are formatted according to dateformat.
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ std::string Config::_defaults =
|
|||
"# Dates\n"
|
||||
"dateformat=m/d/Y # Preferred input and display date format\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.annotation=m/d/Y # Preferred display date format for annotations\n"
|
||||
"weekstart=Sunday # Sunday or Monday only\n"
|
||||
|
|
|
@ -76,12 +76,9 @@ int CmdInfo::execute (std::string& output)
|
|||
undo = context.tdb2.undo.get_lines ();
|
||||
|
||||
// Determine the output date format, which uses a hierarchy of definitions.
|
||||
// rc.report.<report>.dateformat
|
||||
// rc.dateformat.report
|
||||
// rc.dateformat.
|
||||
std::string dateformat = context.config.get ("report.info.dateformat");
|
||||
if (dateformat == "")
|
||||
dateformat = context.config.get ("dateformat.report");
|
||||
// rc.dateformat.info
|
||||
// rc.dateformat
|
||||
std::string dateformat = context.config.get ("dateformat.info");
|
||||
if (dateformat == "")
|
||||
dateformat = context.config.get ("dateformat");
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@ int CmdShow::execute (std::string& output)
|
|||
" dateformat"
|
||||
" dateformat.annotation"
|
||||
" dateformat.holiday"
|
||||
" dateformat.info"
|
||||
" dateformat.report"
|
||||
" debug"
|
||||
" default.command"
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 6;
|
||||
use Test::More tests => 5;
|
||||
|
||||
# Create the rc file.
|
||||
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 test start};
|
||||
|
||||
# Test that report.info.dateformat has precedence over dateformat.report and
|
||||
# dateformat and that no other 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:__};
|
||||
like ($output, qr/__/ms, 'Date formatted according to report.info.dateformat');
|
||||
# Test that dateformat.info has precedence over dateformat and that no other
|
||||
# format is applied
|
||||
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 dateformat.info');
|
||||
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
|
||||
$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');
|
||||
|
||||
### Cleanup.
|
||||
|
|
|
@ -35,6 +35,7 @@ if (open my $fh, '>', 'date1.rc')
|
|||
{
|
||||
print $fh "data.location=.\n",
|
||||
"dateformat=YMD\n",
|
||||
"dateformat.info=YMD\n",
|
||||
"dateformat.report=YMD\n";
|
||||
close $fh;
|
||||
ok (-r 'date1.rc', 'Created date1.rc');
|
||||
|
@ -44,6 +45,7 @@ if (open my $fh, '>', 'date2.rc')
|
|||
{
|
||||
print $fh "data.location=.\n",
|
||||
"dateformat=m/d/y\n",
|
||||
"dateformat.info=m/d/y\n",
|
||||
"dateformat.report=m/d/y\n";
|
||||
close $fh;
|
||||
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",
|
||||
"weekstart=Monday\n",
|
||||
"dateformat.info=A D B Y (vV)\n",
|
||||
"dateformat.report=A D B Y (vV)\n";
|
||||
close $fh;
|
||||
ok (-r 'date3.rc', 'Created date3.rc');
|
||||
|
|
|
@ -35,7 +35,7 @@ if (open my $fh, '>', 'dom.rc')
|
|||
{
|
||||
print $fh "data.location=.\n",
|
||||
"dateformat=YMD\n",
|
||||
"report.info.dateformat=YMD\n";
|
||||
"dateformat.info=YMD\n";
|
||||
close $fh;
|
||||
ok (-r 'dom.rc', 'Created dom.rc');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue