- TW-1522 Date format doesn't like hyphens (thanks to Scott Carter).
This commit is contained in:
Paul Beckingham 2015-01-25 14:49:02 -05:00
parent 4865269630
commit 6626207ad1
11 changed files with 30 additions and 10 deletions

View file

@ -242,3 +242,5 @@ suggestions:
Ozgur Akgun Ozgur Akgun
David Costa David Costa
Sujeevan Vijayakumaran Sujeevan Vijayakumaran
Scott Carter

View file

@ -20,6 +20,7 @@
to Tomas Babej). to Tomas Babej).
- TW-1519 Testing suite forces taskd.trust="ignore hostname" (thanks to Renato - TW-1519 Testing suite forces taskd.trust="ignore hostname" (thanks to Renato
Alves). Alves).
- TW-1522 Date format doesn't like hyphens (thanks to Scott Carter).
- Fixed assorted color theme problems. - Fixed assorted color theme problems.
- Changed assorted reports so they do not use '.age' format for dates that are - Changed assorted reports so they do not use '.age' format for dates that are
in the future, because those are never shown with this format (thanks to in the future, because those are never shown with this format (thanks to

4
NEWS
View file

@ -9,7 +9,9 @@ New commands in taskwarrior 2.4.1
New configuration options in taskwarrior 2.4.1 New configuration options in taskwarrior 2.4.1
- - The 'date.iso' setting allows you to enable (default) or disable support
for ISO-8601 dates. This is because some of you have 'dateformat' settings
that conflict.
Newly deprecated features in taskwarrior 2.4.1 Newly deprecated features in taskwarrior 2.4.1

View file

@ -615,6 +615,10 @@ field that is set. Otherwise, they are set to the corresponding values of
.RE .RE
.RE .RE
.TP
.B date.iso=yes
Enables ISO-8601 date support. The default value is "yes".
.TP .TP
.B weekstart=Sunday .B weekstart=Sunday
Determines the day a week starts. Valid values are Sunday or Monday only. The Determines the day a week starts. Valid values are Sunday or Monday only. The

View file

@ -116,6 +116,7 @@ std::string Config::_defaults =
"dateformat.info=Y-M-D H:N:S # Preferred display date format for information\n" "dateformat.info=Y-M-D H:N:S # Preferred display date format for information\n"
"dateformat.report= # Preferred display date format for reports\n" "dateformat.report= # Preferred display date format for reports\n"
"dateformat.annotation= # Preferred display date format for annotations\n" "dateformat.annotation= # Preferred display date format for annotations\n"
"date.iso=yes # Enable ISO date support\n"
"weekstart=" "weekstart="
STRING_DATE_SUNDAY_LONG STRING_DATE_SUNDAY_LONG
" # Sunday or Monday only\n" " # Sunday or Monday only\n"

View file

@ -658,6 +658,7 @@ void Context::staticInitialization ()
Task::searchCaseSensitive = Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive"); Task::searchCaseSensitive = Variant::searchCaseSensitive = config.getBoolean ("search.case.sensitive");
Task::regex = Variant::searchUsingRegex = config.getBoolean ("regex"); Task::regex = Variant::searchUsingRegex = config.getBoolean ("regex");
Lexer::dateFormat = Variant::dateFormat = config.get ("dateformat"); Lexer::dateFormat = Variant::dateFormat = config.get ("dateformat");
Lexer::isoEnabled = Variant::isoEnabled = config.getBoolean ("date.iso");
std::map <std::string, Column*>::iterator i; std::map <std::string, Column*>::iterator i;
for (i = columns.begin (); i != columns.end (); ++i) for (i = columns.begin (); i != columns.end (); ++i)

View file

@ -34,6 +34,7 @@
#include <i18n.h> #include <i18n.h>
std::string Lexer::dateFormat = ""; std::string Lexer::dateFormat = "";
bool Lexer::isoEnabled = true;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Lexer::Lexer (const std::string& input) Lexer::Lexer (const std::string& input)
@ -732,15 +733,18 @@ void Lexer::dequote (std::string& input)
bool Lexer::is_date (std::string& result) bool Lexer::is_date (std::string& result)
{ {
// Try an ISO date parse. // Try an ISO date parse.
std::string::size_type iso_i = 0; if (isoEnabled)
std::string iso_result;
ISO8601d iso;
iso.ambiguity (_ambiguity);
if (iso.parse (_input.substr (_shift_counter), iso_i))
{ {
result = _input.substr (_shift_counter, iso_i); std::string::size_type iso_i = 0;
while (iso_i--) shift (); std::string iso_result;
return true; ISO8601d iso;
iso.ambiguity (_ambiguity);
if (iso.parse (_input.substr (_shift_counter), iso_i))
{
result = _input.substr (_shift_counter, iso_i);
while (iso_i--) shift ();
return true;
}
} }
// Try a legacy rc.dateformat parse here. // Try a legacy rc.dateformat parse here.

View file

@ -34,6 +34,7 @@ class Lexer
{ {
public: public:
static std::string dateFormat; static std::string dateFormat;
static bool isoEnabled;
enum Type enum Type
{ {

View file

@ -41,6 +41,7 @@
std::string Variant::dateFormat = ""; std::string Variant::dateFormat = "";
bool Variant::searchCaseSensitive = true; bool Variant::searchCaseSensitive = true;
bool Variant::searchUsingRegex = true; bool Variant::searchUsingRegex = true;
bool Variant::isoEnabled = true;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Variant::Variant () Variant::Variant ()
@ -2065,7 +2066,8 @@ void Variant::cast (const enum type new_type)
ISO8601d iso; ISO8601d iso;
std::string::size_type pos = 0; std::string::size_type pos = 0;
if (iso.parse (_string, pos) && if (isoEnabled &&
iso.parse (_string, pos) &&
pos == _string.length ()) pos == _string.length ())
{ {
_date = (time_t) iso; _date = (time_t) iso;

View file

@ -37,6 +37,7 @@ public:
static std::string dateFormat; static std::string dateFormat;
static bool searchCaseSensitive; static bool searchCaseSensitive;
static bool searchUsingRegex; static bool searchUsingRegex;
static bool isoEnabled;
enum type {type_unknown, type_boolean, type_integer, type_real, type_string, enum type {type_unknown, type_boolean, type_integer, type_real, type_string,
type_date, type_duration}; type_date, type_duration};

View file

@ -134,6 +134,7 @@ int CmdShow::execute (std::string& output)
" dateformat.holiday" " dateformat.holiday"
" dateformat.info" " dateformat.info"
" dateformat.report" " dateformat.report"
" date.iso"
" debug" " debug"
" debug.hooks" " debug.hooks"
" debug.parser" " debug.parser"