From 189fdaf9ac56a4b633404fe6f3a7caaf5f8edb69 Mon Sep 17 00:00:00 2001 From: Cory Donnelly Date: Wed, 28 Jul 2010 10:18:34 -0400 Subject: [PATCH 1/2] Bug #444 - Interactive undo locks pending.data and doesn't give it up - TDB::undo () now exits gracefully when a user declines to proceed with the undo, ensuring context.tdb.unlock () is called --- ChangeLog | 2 ++ src/TDB.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e079ecee7..4f6ab6623 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,8 @@ substitution (thanks to Michelle Crane). + Fixed problem with command line configuration overrides that had no values. + + Fixed bug #444, which made task shell unusable after canceling out of an + undo command. ------ old releases ------------------------------ diff --git a/src/TDB.cpp b/src/TDB.cpp index 2429cdcbf..856a0cbd5 100644 --- a/src/TDB.cpp +++ b/src/TDB.cpp @@ -933,7 +933,11 @@ void TDB::undo () // Output displayed, now confirm. if (!confirm ("The undo command is not reversible. Are you sure you want to revert to the previous state?")) - throw std::string ("No changes made."); + { + std::cout << "No changes made." << std::endl; + context.hooks.trigger ("post-undo"); + return; + } // Extract identifying uuid. std::string uuid; From 903b5b34d41cecf1328c3270868f22a22e5e8827 Mon Sep 17 00:00:00 2001 From: Federico Hernandez Date: Wed, 28 Jul 2010 18:07:09 +0200 Subject: [PATCH 2/2] Feature #446 - start of {week, month, year} - Bug fix for som and soy. - Added synonyms soww and eoww for sow and eow. - Added start/end of calendar week: socw and eocw. --- ChangeLog | 1 + NEWS | 3 +++ doc/man/task.1 | 26 ++++++++++++++++++-------- src/Date.cpp | 34 ++++++++++++++++++++++++++-------- src/tests/date.t.cpp | 12 +++++++++--- 5 files changed, 57 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index e079ecee7..1b26a0bc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,7 @@ command. + Added feature #446, task supports now 'sow', 'som' and 'soy' as dates for 'due', 'wait' and 'until' (thanks to T. Charles Yun). + Added as well synonyms soww/eoww plus new socw/eocw for calendar weeks. + New 'depends' column for custom reports. + New 'blocked' report for showing blocked tasks. + Improved man pages (thanks to Andy Lester). diff --git a/NEWS b/NEWS index 0950dc456..ee39b3743 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,9 @@ New configuration options in task 1.9.3 - journal.time, journal.time.start.annotation, journal.time.stop.annotation - 'sow', 'som' and 'soy' are now accepted in dates + 'soww' and 'eoww' are now synonyms for 'sow' and 'eow' (ww = working week) + 'socw' and 'eocw' refer to the calendar week (starting Sunday/Monday and + ending Saturday/Sunday) Newly deprecated features in task 1.9.3 diff --git a/doc/man/task.1 b/doc/man/task.1 index a431daf13..58d4a1597 100644 --- a/doc/man/task.1 +++ b/doc/man/task.1 @@ -387,21 +387,31 @@ task ... due:1day task ... due:9hrs .TP -End of week (Friday), month and year -task ... due:eow +Start of (work) week (Monday), calendar week (Sunday or Monday), month and year .br -task ... due:eom -.br -task ... due:eoy - -.TP -Start of week (Sunday or Monday), month and year task ... due:sow .br +task ... due:soww +.br +task ... due:socw +.br task ... due:som .br task ... due:soy +.TP +End of (work) week (Friday), calendar week (Saturday or Sunday), month and year +.br +task ... due:eow +.br +task ... due:eoww +.br +task ... due:eocw +.br +task ... due:eom +.br +task ... due:eoy + .TP Next occurring weekday task ... due:fri diff --git a/src/Date.cpp b/src/Date.cpp index 049d64c28..64d7f58c3 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -885,9 +885,13 @@ bool Date::isRelativeDate (const std::string& input) supported.push_back ("tomorrow"); supported.push_back ("yesterday"); supported.push_back ("eow"); + supported.push_back ("eoww"); + supported.push_back ("eocw"); supported.push_back ("eom"); supported.push_back ("eoy"); supported.push_back ("sow"); + supported.push_back ("soww"); + supported.push_back ("socw"); supported.push_back ("som"); supported.push_back ("soy"); supported.push_back ("goodfriday"); @@ -907,14 +911,23 @@ bool Date::isRelativeDate (const std::string& input) int dow; if ((dow = Date::dayOfWeek (found)) != -1 || found == "eow" || + found == "eoww" || found == "eocw" || - found == "sow") + found == "sow" || + found == "soww" || + found == "socw") { - if (found == "eow") + if (found == "eow" || found == "eoww") dow = 5; - if (found == "sow") - dow =Date::dayOfWeek (context.config.get ("weekstart")); + if (found == "eocw") + dow = (Date::dayOfWeek (context.config.get ("weekstart")) + 6) % 7; + + if (found == "sow" || found == "soww") + dow = 1; + + if (found == "socw") + dow = Date::dayOfWeek (context.config.get ("weekstart")); if (today.dayOfWeek () >= dow) today += (dow - today.dayOfWeek () + 7) * 86400; @@ -968,15 +981,20 @@ bool Date::isRelativeDate (const std::string& input) } else if (found == "som") { - Date then (today.month (), - 1, - today.year ()); + int m = today.month () + 1; + int y = today.year (); + if (m > 12) + { + m -=12; + y++; + } + Date then (m, 1, y); mT = then.mT; return true; } else if (found == "soy") { - Date then (1, 1, today.year ()); + Date then (1, 1, today.year () + 1); mT = then.mT; return true; } diff --git a/src/tests/date.t.cpp b/src/tests/date.t.cpp index dd818642f..23134979f 100644 --- a/src/tests/date.t.cpp +++ b/src/tests/date.t.cpp @@ -34,7 +34,7 @@ Context context; //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (147); + UnitTest t (149); try { @@ -301,6 +301,9 @@ int main (int argc, char** argv) Date r11 ("eow"); t.ok (r11 < now + (8 * 86400), "eow < 7 days away"); + Date r20 ("eocw"); + t.ok (r20 < now + (8 * 86400), "eocw < 7 days away"); + Date r12 ("eom"); t.ok (r12.sameMonth (now), "eom in same month as now"); @@ -310,11 +313,14 @@ int main (int argc, char** argv) Date r14 ("sow"); t.ok (r14 < now + (8 * 86400), "sow < 7 days away"); + Date r21 ("socw"); + t.ok (r21 < now + (8 * 86400), "sow < 7 days away"); + Date r15 ("som"); - t.ok (r15.sameMonth (now), "eom in same month as now"); + t.notok (r15.sameMonth (now), "som not in same month as now"); Date r16 ("soy"); - t.ok (r16.sameYear (now), "eoy in same year as now"); + t.notok (r16.sameYear (now), "soy not in same year as now"); // Date::sameHour Date r17 ("6/7/2010 01:00:00", "m/d/Y H:N:S");