Mercurial > octave-nkf
changeset 19418:7d272300a880 stable
datevec.m: Fix negative number outputs with integer (non-float) inputs (bug #43753).
* datevec.m: Use double() to cast input before doing further calculations.
Add BIST tests to check correct behavior.
author | Nir Krakauer <nkrakauer@ccny.cuny.edu> |
---|---|
date | Fri, 05 Dec 2014 12:36:06 -0800 |
parents | ef649fe230f5 |
children | 616f2b22787b |
files | scripts/time/datevec.m |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/time/datevec.m Fri Dec 05 11:07:36 2014 -0800 +++ b/scripts/time/datevec.m Fri Dec 05 12:36:06 2014 -0800 @@ -149,7 +149,7 @@ date = date(:); ## Move day 0 from midnight -0001-12-31 to midnight 0000-3-1 - z = floor (date) - 60; + z = double (floor (date) - 60); ## Calculate number of centuries; K1 = 0.25 is to avoid rounding problems. a = floor ((z - 0.25) / 36524.25); ## Days within century; K2 = 0.25 is to avoid rounding problems. @@ -314,4 +314,6 @@ %!test %! t = linspace (-2e5, 2e5, 10993); %! assert (all (abs (datenum (datevec (t)) - t') < 1e-5)); +%!assert (double (datevec (int64 (datenum ([2014 6 1])))), datevec (datenum ([2014 6 1]))) +%!assert (double (datevec (int64 (datenum ([2014 6 18])))), datevec (datenum ([2014 6 18])))