1 ## Copyright (C) 1995-2012 John W. Eaton
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} clock ()
21 ## Return the current local date and time as a date vector. The date vector
22 ## contains the following fields: current year, month (1-12), day (1-31),
23 ## hour (0-23), minute (0-59), and second (0-61). The seconds field has
24 ## a fractional part after the decimal point for extended accuracy.
31 ## @result{} [ 1993, 8, 20, 4, 56, 1 ]
35 ## The function clock is more accurate on systems that have the
36 ## @code{gettimeofday} function.
37 ## @seealso{now, date, datevec}
42 function retval = clock ()
44 tm = localtime (time ());
46 retval = zeros (1, 6);
48 retval(1) = tm.year + 1900;
49 retval(2) = tm.mon + 1;
53 retval(6) = tm.sec + tm.usec / 1e6;
59 %! t2 = str2num (strftime ("[%Y, %m, %d, %H, %M, %S]", localtime (time ())));
60 %! assert(etime (t1, t2) < 1);