8920
|
1 ## Copyright (C) 1995, 1996, 1997, 1999, 2000, 2002, 2005, 2006, 2007, 2008 |
7017
|
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 |
3295
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} ctime (@var{t}) |
|
22 ## Convert a value returned from @code{time} (or any other nonnegative |
|
23 ## integer), to the local time and return a string of the same form as |
|
24 ## @code{asctime}. The function @code{ctime (time)} is equivalent to |
|
25 ## @code{asctime (localtime (time))}. For example, |
3426
|
26 ## |
3295
|
27 ## @example |
|
28 ## @group |
|
29 ## ctime (time ()) |
4003
|
30 ## @result{} "Mon Feb 17 01:15:06 1997\n" |
3295
|
31 ## @end group |
|
32 ## @end example |
|
33 ## @end deftypefn |
1183
|
34 |
2314
|
35 ## Author: jwe |
|
36 |
2311
|
37 function retval = ctime (t) |
1183
|
38 |
|
39 if (nargin == 1) |
|
40 retval = asctime (localtime (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 ctime (); |
|
52 |
|
53 %!error ctime (1, 2); |
|
54 |