Mercurial > octave
comparison 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 |
comparison
equal
deleted
inserted
replaced
30647:e9bfb92dab01 | 30648:c7a515aa767e |
---|---|
206 | 206 |
207 function [f, rY, ry, fy, fm, fd, fh, fmi, fs] = __date_vfmt2sfmt__ (f) | 207 function [f, rY, ry, fy, fm, fd, fh, fmi, fs] = __date_vfmt2sfmt__ (f) |
208 | 208 |
209 original_f = f; # Store for error messages. | 209 original_f = f; # Store for error messages. |
210 | 210 |
211 if (any (ismember (f, "hsfYD"))) | 211 if (any (strchr (f, "hsfYD", 1))) |
212 warning ("Octave:date-format-spec:wrong-case", ... | 212 warning ("Octave:datevec:date-format-spec", ... |
213 ["datevec: Format specifiers for dates should be lower case,", ... | 213 ["datevec: Format specifiers for dates should be lower case,", ... |
214 " format specifiers for time should be upper case. ", ... | 214 " format specifiers for time should be upper case. ", ... |
215 " Possible issue with 'm' (month) and 'M' (minutes)?"]); | 215 " Possible issue with 'm' (month) and 'M' (minutes)?"]); |
216 endif | 216 endif |
217 | 217 |
466 %!error <multiple month specifiers> datevec ("1/2/30", "mm/mm/yy") | 466 %!error <multiple month specifiers> datevec ("1/2/30", "mm/mm/yy") |
467 %!error <multiple day specifiers> datevec ("1/2/30", "mm/dd/dd") | 467 %!error <multiple day specifiers> datevec ("1/2/30", "mm/dd/dd") |
468 %!error <multiple hour specifiers> datevec ("15:38:21.251", "HH:HH:SS") | 468 %!error <multiple hour specifiers> datevec ("15:38:21.251", "HH:HH:SS") |
469 %!error <multiple minute specifiers> datevec ("15:38:21.251", "MM:MM:SS") | 469 %!error <multiple minute specifiers> datevec ("15:38:21.251", "MM:MM:SS") |
470 %!error <multiple second specifiers> datevec ("15:38:21.251", "HH:SS:SS") | 470 %!error <multiple second specifiers> datevec ("15:38:21.251", "HH:SS:SS") |
471 %!fail ("datevec ('2015-03-31 0:00','YYYY-mm-DD HH:MM')", ... | |
472 %! "warning", "Format specifiers for dates should be lower case"); | |
473 %!fail ("datevec ('2015-03-31 0:00','yyyy-mm-dd hh:mm')", ... | |
474 %! "warning", "Format specifiers for time should be upper case"); | |
475 |