Mercurial > hg > octave-lyh
annotate scripts/time/clock.m @ 11477:a02d00dd3d5f
expm.m: new tests
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 10 Jan 2011 14:50:33 -0500 |
parents | 693e22af08ae |
children | fd0a3ac60b0e |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 1995, 1996, 1997, 1999, 2000, 2005, 2007, 2008 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
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. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
1183 | 18 |
3301 | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} clock () | |
21 ## Return a vector containing the current year, month (1-12), day (1-31), | |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
22 ## hour (0-23), minute (0-59) and second (0-61). For example: |
3426 | 23 ## |
3301 | 24 ## @example |
25 ## @group | |
26 ## clock () | |
27 ## @result{} [ 1993, 8, 20, 4, 56, 1 ] | |
28 ## @end group | |
29 ## @end example | |
3426 | 30 ## |
3301 | 31 ## The function clock is more accurate on systems that have the |
32 ## @code{gettimeofday} function. | |
33 ## @end deftypefn | |
1183 | 34 |
2314 | 35 ## Author: jwe |
36 | |
2311 | 37 function retval = clock () |
1183 | 38 |
39 tm = localtime (time ()); | |
40 | |
41 retval = zeros (1, 6); | |
42 | |
1374 | 43 retval(1) = tm.year + 1900; |
44 retval(2) = tm.mon + 1; | |
45 retval(3) = tm.mday; | |
46 retval(4) = tm.hour; | |
47 retval(5) = tm.min; | |
48 retval(6) = tm.sec + tm.usec / 1e6; | |
1183 | 49 |
50 endfunction | |
7411 | 51 |
52 %!test | |
53 %! t1 = clock; | |
54 %! t2 = str2num (strftime ("[%Y, %m, %d, %H, %M, %S]", localtime (time ()))); | |
55 %! assert(etime (t1, t2) < 1); | |
56 |