TW-1716: on-modify hooks fail if date.iso is not set

- Thanks to Jens Erat.
This commit is contained in:
Paul Beckingham 2015-10-18 10:47:25 -04:00
parent 2272ba71a2
commit 10ebefa8eb
3 changed files with 30 additions and 7 deletions

View file

@ -164,6 +164,7 @@
- TW-1701 Some generated UUIDs deemed invalid (thanks to Wim Schuermann). - TW-1701 Some generated UUIDs deemed invalid (thanks to Wim Schuermann).
- TW-1707 Context can leak into modifications (thanks to Tomas Babej). - TW-1707 Context can leak into modifications (thanks to Tomas Babej).
- TW-1715 Dates misinterpreted when no dateformat active. - TW-1715 Dates misinterpreted when no dateformat active.
- TW-1716 on-modify hooks fail if `date.iso` is not set (thanks to Jens Erat).
- Prevent potential task duplication during import for non-pending tasks. - Prevent potential task duplication during import for non-pending tasks.
- Show the active context in "context list", if any is active. - Show the active context in "context list", if any is active.
- Fix "task edit" dropping annotation text after newlines. - Fix "task edit" dropping annotation text after newlines.

View file

@ -247,13 +247,18 @@ bool ISO8601d::parse (
} }
} }
else if (ISO8601d::isoEnabled && // Allow parse_date_time and parse_date_time_ext regardless of
(parse_date_time (n) || // Strictest first. // ISO8601d::isoEnabled setting, because these formats are relied upon by
// the 'import' command, JSON parser and hook system.
else if (parse_date_time (n) || // Strictest first.
parse_date_time_ext (n) ||
(ISO8601d::isoEnabled &&
(parse_date_time (n) ||
parse_date_time_ext (n) || parse_date_time_ext (n) ||
parse_date_ext (n) || parse_date_ext (n) ||
parse_time_utc_ext (n) || parse_time_utc_ext (n) ||
parse_time_off_ext (n) || parse_time_off_ext (n) ||
parse_time_ext (n))) // Time last, as it is the most permissive. parse_time_ext (n)))) // Time last, as it is the most permissive.
{ {
// Check the values and determine time_t. // Check the values and determine time_t.
if (validate ()) if (validate ())

View file

@ -302,6 +302,23 @@ class TestImportValidate(TestCase):
self.assertIn("The status 'foo' is not valid.", err) self.assertIn("The status 'foo' is not valid.", err)
class TestImportWithoutISO(TestCase):
def setUp(self):
self.t = Task()
def test_import_with_iso_enabled(self):
j = '{"uuid":"a2a2a2a2-a2a2-a2a2-a2a2-a2a2a2a2a2a2", "description":"one", "entry":"20151018T144200"}'
self.t("import rc.date.iso=1", input=j)
code, out, err = self.t("_get 1.entry")
self.assertIn("2015-10-18T14:42:00\n", out)
def test_import_with_iso_disabled(self):
j = '{"uuid":"a2a2a2a2-a2a2-a2a2-a2a2-a2a2a2a2a2a2", "description":"one", "entry":"20151018T144200"}'
self.t("import rc.date.iso=0", input=j)
code, out, err = self.t("_get 1.entry")
self.assertIn("2015-10-18T14:42:00\n", out)
if __name__ == "__main__": if __name__ == "__main__":
from simpletap import TAPTestRunner from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner()) unittest.main(testRunner=TAPTestRunner())