Mercurial > hg > octave-lyh
changeset 5860:b645066d40ad
[project @ 2006-06-16 05:01:38 by jwe]
author | jwe |
---|---|
date | Fri, 16 Jun 2006 05:01:39 +0000 |
parents | ba0bea22167b |
children | 2a6cb4ed8f1e |
files | scripts/ChangeLog scripts/time/datevec.m |
diffstat | 2 files changed, 9 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2006-06-16 John W. Eaton <jwe@octave.org> + + * time/datevec.m: Avoid computing log of non-positive values. + 2006-06-14 John W. Eaton <jwe@octave.org> * time/datevec.m: Attempt to account for precision of datenum format.
--- a/scripts/time/datevec.m +++ b/scripts/time/datevec.m @@ -156,7 +156,10 @@ ## datenum format. fracd = date - floor (date); - srnd = 10 .^ floor (log10 (365.25*y)); + ## Special case for total days <= 0. + tmpd = abs (365.25*y); + tmpd(tmpd == 0) = 1; + srnd = 10 .^ floor (log10 (tmpd)); s = round (86400*fracd.*srnd) ./ srnd; h = floor (s / 3600); s = s - 3600 * h; @@ -300,7 +303,7 @@ %!assert(all(datenum(datevec([-1e4:1e4]))==[-1e4:1e4]')) %!test %! t = linspace (-2e5, 2e5, 10993); -%! assert (all (datenum (datevec (t)) == t')); +%! assert (all (abs (datenum (datevec (t)) - t') < 1e-5)); # demos %!demo %! datevec (now ())