From 82a4607ec61020c2ffb5af16c137b99ba474d044 Mon Sep 17 00:00:00 2001 From: Louis-Claude Canon Date: Wed, 16 May 2012 17:39:55 +0200 Subject: [PATCH] Enhancement - Separate date format when editing from the default one. --- doc/man/taskrc.5.in | 2 ++ src/Config.cpp | 1 + src/commands/CmdEdit.cpp | 8 ++++++-- src/commands/CmdShow.cpp | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index db3958f62..1264a009d 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -475,6 +475,8 @@ Enables the extension system. Defaults to on. .TP .B dateformat.holiday=YMD .TP +.B dateformat.edit=m/d/Y H:N:S +.TP .B dateformat.info=m/d/Y H:N:S .TP .B dateformat.annotation=m/d/Y diff --git a/src/Config.cpp b/src/Config.cpp index 28058dde2..999874838 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.edit=m/d/Y H:N:S # Preferred display date format when editing\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" diff --git a/src/commands/CmdEdit.cpp b/src/commands/CmdEdit.cpp index 948cc9c64..defba0a17 100644 --- a/src/commands/CmdEdit.cpp +++ b/src/commands/CmdEdit.cpp @@ -631,8 +631,12 @@ bool CmdEdit::editFile (Task& task) file << "task." << getpid () << "." << task.id << ".task"; std::string path = location._data + "/" + file.str (); - // Determine the output date format - std::string dateformat = context.config.get ("dateformat"); + // Determine the output date format, which uses a hierarchy of definitions. + // rc.dateformat.edit + // rc.dateformat + std::string dateformat = context.config.get ("dateformat.edit"); + if (dateformat == "") + dateformat = context.config.get ("dateformat"); // Format the contents, T -> text, write to a file. std::string before = formatTask (task, dateformat); diff --git a/src/commands/CmdShow.cpp b/src/commands/CmdShow.cpp index 6db2cbeda..107676b51 100644 --- a/src/commands/CmdShow.cpp +++ b/src/commands/CmdShow.cpp @@ -128,6 +128,7 @@ int CmdShow::execute (std::string& output) " data.location" " dateformat" " dateformat.annotation" + " dateformat.edit" " dateformat.holiday" " dateformat.info" " dateformat.report"