Mercurial > hg > octave-lyh
diff scripts/time/datetick.m @ 10151:c2f1cdb59821
datetick: make form argument optional
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 20 Jan 2010 14:48:13 -0500 |
parents | 16f53d29049f |
children | 3516a245d607 |
line wrap: on
line diff
--- a/scripts/time/datetick.m +++ b/scripts/time/datetick.m @@ -17,7 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} datetick (@var{form}) +## @deftypefn {Function File} {} datetick () +## @deftypefnx {Function File} {} datetick (@var{form}) ## @deftypefnx {Function File} {} datetick (@var{axis}, @var{form}) ## @deftypefnx {Function File} {} datetick (@dots{}, "keeplimits") ## @deftypefnx {Function File} {} datetick (@dots{}, "keepticks") @@ -35,17 +36,14 @@ [h, varargin, nargin] = __plt_get_axis_arg__ ("datetick", varargin{:}); - if (nargin < 1) - print_usage (); - else - oldh = gca (); - unwind_protect - axes (h); - __datetick__ (varargin{:}); - unwind_protect_cleanup - axes (oldh); - end_unwind_protect - endif + oldh = gca (); + unwind_protect + axes (h); + __datetick__ (varargin{:}); + unwind_protect_cleanup + axes (oldh); + end_unwind_protect + endfunction %!demo @@ -104,12 +102,14 @@ startdate = []; endif - if (isnumeric (form)) - if (! isscalar (form) || floor (form) != form || form < 0) - error ("datetick: expecting form argument to be a positive integer"); + if (! isempty (form)) + if (isnumeric (form)) + if (! isscalar (form) || floor (form) != form || form < 0) + error ("datetick: expecting form argument to be a positive integer"); + endif + elseif (! ischar (form)) + error ("datetick: expecting valid date format string"); endif - elseif (! ischar (form) && !isempty (form)) - error ("datetick: expecting valid date format string"); endif if (keeptick) @@ -192,6 +192,8 @@ ## days form = 8; elseif r < 365 + ## FIXME -- FORM should be 19 for European users who use dd/mm + ## instead of mm/dd. How can that be determined automatically? ## months form = 6; elseif r < 90*12