diff scripts/time/datevec.m @ 30648:c7a515aa767e

datevec.m: Tweaks to cset e9bfb92dab01 for performance and documentation (bug #47627) * datevec.m: Use strchr() rather than ismember() for 2.25X speedup. Change warning ID for bad date format specification to follow Octave conventions. Add BIST tests for new warning. * warning_ids.m: Document new "Octave:datevec:date-format-spec" warning.
author Rik <rik@octave.org>
date Fri, 14 Jan 2022 11:08:44 -0800
parents e9bfb92dab01
children 744778e9210b
line wrap: on
line diff
--- a/scripts/time/datevec.m	Fri Jan 14 18:27:06 2022 +0100
+++ b/scripts/time/datevec.m	Fri Jan 14 11:08:44 2022 -0800
@@ -208,8 +208,8 @@
 
   original_f = f;   # Store for error messages.
 
-  if (any (ismember (f, "hsfYD")))
-    warning ("Octave:date-format-spec:wrong-case", ...
+  if (any (strchr (f, "hsfYD", 1)))
+    warning ("Octave:datevec:date-format-spec", ...
              ["datevec: Format specifiers for dates should be lower case,", ...
               " format specifiers for time should be upper case. ", ...
               " Possible issue with 'm' (month) and 'M' (minutes)?"]);
@@ -468,3 +468,8 @@
 %!error <multiple hour specifiers> datevec ("15:38:21.251", "HH:HH:SS")
 %!error <multiple minute specifiers> datevec ("15:38:21.251", "MM:MM:SS")
 %!error <multiple second specifiers> datevec ("15:38:21.251", "HH:SS:SS")
+%!fail ("datevec ('2015-03-31 0:00','YYYY-mm-DD HH:MM')", ...
+%!      "warning", "Format specifiers for dates should be lower case");
+%!fail ("datevec ('2015-03-31 0:00','yyyy-mm-dd hh:mm')", ...
+%!      "warning", "Format specifiers for time should be upper case");
+