diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 94bb45ff9..db3958f62 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -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. diff --git a/src/Config.cpp b/src/Config.cpp index d3edd151e..28058dde2 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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" diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 6a970e0e1..c9e5f118c 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -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..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"); diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index 095d5de29..6db2cbeda 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -129,6 +129,7 @@ int CmdShow::execute (std::string& output) " dateformat" " dateformat.annotation" " dateformat.holiday" + " dateformat.info" " dateformat.report" " debug" " default.command" diff --git a/test/bug.986.t b/test/bug.986.t index b6e38bcd1..fd4b63eb9 100755 --- a/test/bug.986.t +++ b/test/bug.986.t @@ -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. diff --git a/test/dateformat.t b/test/dateformat.t index 825a552cb..c6f65da12 100755 --- a/test/dateformat.t +++ b/test/dateformat.t @@ -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'); diff --git a/test/dom.2.t b/test/dom.2.t index f97fbb0e5..d9c6711cc 100755 --- a/test/dom.2.t +++ b/test/dom.2.t @@ -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'); }