Mercurial > octave-nkf
diff scripts/time/asctime.m @ 13856:d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
* addtodate.m: Add millisecond functionality. Update docstring and %!tests.
* calendar.m: Implement faster way to add '*' to day display. Update docstring.
* weekday.m: Use more modern coding stytle. Update docstring.
* asctime.m, clock.m, ctime.m, date.m, datenum.m, datestr.m, datevec.m,
eomday.m, etime.m, is_leap_year.m: Update docstring and/or use Octave formatting
spacing conventions for %!tests.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 10 Nov 2011 13:35:08 -0800 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
line wrap: on
line diff
--- a/scripts/time/asctime.m Thu Nov 10 02:50:51 2011 -0500 +++ b/scripts/time/asctime.m Thu Nov 10 13:35:08 2011 -0800 @@ -18,36 +18,37 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} asctime (@var{tm_struct}) -## Convert a time structure to a string using the following five-field -## format: Thu Mar 28 08:40:14 1996. For example: +## Convert a time structure to a string using the following +## format: "ddd mmm mm HH:MM:SS yyyy". For example: ## ## @example ## @group ## asctime (localtime (time ())) -## @result{} "Mon Feb 17 01:15:06 1997\n" +## @result{} "Mon Feb 17 01:15:06 1997" ## @end group ## @end example ## ## This is equivalent to @code{ctime (time ())}. +## @seealso{ctime, localtime, time} ## @end deftypefn ## Author: jwe function retval = asctime (tm_struct) - if (nargin == 1) - retval = strftime ("%a %b %d %H:%M:%S %Y\n", tm_struct); - else + if (nargin != 1) print_usage (); endif + retval = strftime ("%a %b %d %H:%M:%S %Y\n", tm_struct); + endfunction + %!test %! t = time (); %! assert(strcmp (asctime (localtime (t)), ctime (t))); %!error asctime (); - %!error asctime (1, 2);