Mercurial > octave
changeset 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 |
files | scripts/help/warning_ids.m scripts/time/datevec.m |
diffstat | 2 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/help/warning_ids.m Fri Jan 14 18:27:06 2022 +0100 +++ b/scripts/help/warning_ids.m Fri Jan 14 11:08:44 2022 -0800 @@ -178,6 +178,13 @@ ## different file target than the programmer intended is being used. ## By default, the @code{Octave:data-file-in-path} warning is enabled. ## +## @item Octave:datevec:date-format-spec +## If the @code{Octave:datevec:date-format-spec} warning is enabled, a warning +## is printed if the date format specification contains questionable date or +## time specifiers. Typical bad patterns are using upper case date specifiers +## or lower case time specifiers. +## By default, the @code{Octave:datevec:date-format-spec} warning is enabled. +## ## @item Octave:deprecated-function ## If the @code{Octave:deprecated-function} warning is enabled, a ## warning is issued when Octave encounters a function that is obsolete and
--- 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"); +