Mercurial > hg > octave-nkf
changeset 14737:94a8366f9f89
datenum.m: Ensure all inputs are of class double (Bug #36587).
* datenum.m: Ensure all inputs are of class double. Add tests for new behavior.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 05 Jun 2012 16:11:25 -0700 |
parents | 295bd3efc065 |
children | 31e2c4248664 |
files | scripts/time/datenum.m |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/time/datenum.m +++ b/scripts/time/datenum.m @@ -109,7 +109,12 @@ endif endif - month(month<1) = 1; ## For compatibility. Otherwise allow negative months. + if (! (isa (year, "double") && isa (month, "double") && isa (day, "double") && + isa (hour, "double") && isa (minute, "double") && isa (second, "double"))) + error ("datenum: all inputs must be of class double"); + endif + + month(month<1) = 1; # For compatibility. Otherwise allow negative months. ## Treat fractional months, by converting the fraction to days if (floor (month) != month) @@ -195,5 +200,6 @@ %% Test input validation %!error datenum () %!error datenum (1,2,3,4,5,6,7) -%!error datenum ([1, 2]) -%!error datenum ([1,2,3,4,5,6,7]) +%!error <expected date vector containing> datenum ([1, 2]) +%!error <expected date vector containing> datenum ([1,2,3,4,5,6,7]) +%!error <all inputs must be of class double> datenum (int32 (2000), int32 (1), int32 (1))