Mercurial > hg > octave-nkf
annotate scripts/time/clock.m @ 20830:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 2645f9ef8c88 |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 1995-2015 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 () | |
20372
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
21 ## Return the current local date and time as a date vector. |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
22 ## |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
23 ## The date vector contains the following fields: current year, month (1-12), |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
24 ## day (1-31), hour (0-23), minute (0-59), and second (0-61). The seconds |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
25 ## field has a fractional part after the decimal point for extended accuracy. |
13856
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
26 ## |
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
27 ## For example: |
3426 | 28 ## |
3301 | 29 ## @example |
30 ## @group | |
13856
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
31 ## fix (clock ()) |
3301 | 32 ## @result{} [ 1993, 8, 20, 4, 56, 1 ] |
33 ## @end group | |
34 ## @end example | |
3426 | 35 ## |
20372
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
36 ## @code{clock} is more accurate on systems that have the @code{gettimeofday} |
2645f9ef8c88
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
37 ## function. |
13856
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
38 ## @seealso{now, date, datevec} |
3301 | 39 ## @end deftypefn |
1183 | 40 |
2314 | 41 ## Author: jwe |
42 | |
2311 | 43 function retval = clock () |
1183 | 44 |
45 tm = localtime (time ()); | |
46 | |
47 retval = zeros (1, 6); | |
48 | |
1374 | 49 retval(1) = tm.year + 1900; |
50 retval(2) = tm.mon + 1; | |
51 retval(3) = tm.mday; | |
52 retval(4) = tm.hour; | |
53 retval(5) = tm.min; | |
54 retval(6) = tm.sec + tm.usec / 1e6; | |
1183 | 55 |
56 endfunction | |
7411 | 57 |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
58 |
7411 | 59 %!test |
60 %! t1 = clock; | |
61 %! t2 = str2num (strftime ("[%Y, %m, %d, %H, %M, %S]", localtime (time ()))); | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
62 %! assert (etime (t1, t2) < 1); |
7411 | 63 |