7017
|
1 ## Copyright (C) 1995, 1996, 1997, 1999, 2000, 2005, 2006, 2007 |
|
2 ## John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
1183
|
19 |
3301
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} asctime (@var{tm_struct}) |
|
22 ## Convert a time structure to a string using the following five-field |
|
23 ## format: Thu Mar 28 08:40:14 1996. For example, |
3426
|
24 ## |
3301
|
25 ## @example |
|
26 ## @group |
7097
|
27 ## asctime (localtime (time ())) |
3301
|
28 ## @result{} "Mon Feb 17 01:15:06 1997\n" |
|
29 ## @end group |
|
30 ## @end example |
3426
|
31 ## |
3301
|
32 ## This is equivalent to @code{ctime (time ())}. |
|
33 ## @end deftypefn |
1183
|
34 |
2314
|
35 ## Author: jwe |
|
36 |
2311
|
37 function retval = asctime (t) |
1183
|
38 |
|
39 if (nargin == 1) |
|
40 retval = strftime ("%a %b %d %H:%M:%S %Y\n", t); |
|
41 else |
6046
|
42 print_usage (); |
1183
|
43 endif |
|
44 |
|
45 endfunction |
7411
|
46 |
|
47 %!test |
|
48 %! t = time (); |
|
49 %! assert(strcmp (asctime (localtime (t)), ctime (t))); |
|
50 |
|
51 %!error asctime (); |
|
52 |
|
53 %!error asctime (1, 2); |
|
54 |