diff --git a/ChangeLog b/ChangeLog index d93f1feb7..fbeba5e0f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -164,6 +164,7 @@ - TW-1701 Some generated UUIDs deemed invalid (thanks to Wim Schuermann). - TW-1707 Context can leak into modifications (thanks to Tomas Babej). - 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. - Show the active context in "context list", if any is active. - Fix "task edit" dropping annotation text after newlines. diff --git a/src/ISO8601.cpp b/src/ISO8601.cpp index d420b0aef..e1b1c82ce 100644 --- a/src/ISO8601.cpp +++ b/src/ISO8601.cpp @@ -247,13 +247,18 @@ bool ISO8601d::parse ( } } - else if (ISO8601d::isoEnabled && - (parse_date_time (n) || // Strictest first. - parse_date_time_ext (n) || - parse_date_ext (n) || - parse_time_utc_ext (n) || - parse_time_off_ext (n) || - parse_time_ext (n))) // Time last, as it is the most permissive. + // Allow parse_date_time and parse_date_time_ext regardless of + // 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_ext (n) || + parse_time_utc_ext (n) || + parse_time_off_ext (n) || + parse_time_ext (n)))) // Time last, as it is the most permissive. { // Check the values and determine time_t. if (validate ()) diff --git a/test/import.t b/test/import.t index 4431dea7e..3d3bc02b6 100755 --- a/test/import.t +++ b/test/import.t @@ -302,6 +302,23 @@ class TestImportValidate(TestCase): 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__": from simpletap import TAPTestRunner unittest.main(testRunner=TAPTestRunner())