Mercurial > hg > octave-nkf
annotate scripts/time/clock.m @ 15116:3d7a7ae53bbf gui
Further integration of GUI in the build system.
* Makefile.am (SUBDIRS): Add gui conditionally.
* configure.ac (AC_CHECK_PROGS(rcc)): Check for new program.
(AC_ARG_ENABLE(gui): New configure flag.
* gui/src/Makefile.am: Add support for resource file compilation.
Use nodist_XXX_SOURCES for MOC files.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sun, 05 Aug 2012 20:04:53 +0100 |
parents | f3d52523cde1 |
children | 1c89599167a6 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13856
diff
changeset
|
1 ## Copyright (C) 1995-2012 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 () | |
13856
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
21 ## Return the current local date and time as a date vector. The date vector |
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
22 ## contains the following fields: current year, month (1-12), day (1-31), |
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
23 ## hour (0-23), minute (0-59), and second (0-61). The seconds field has |
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
24 ## a fractional part after the decimal point for extended accuracy. |
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
25 ## |
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
26 ## For example: |
3426 | 27 ## |
3301 | 28 ## @example |
29 ## @group | |
13856
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
30 ## fix (clock ()) |
3301 | 31 ## @result{} [ 1993, 8, 20, 4, 56, 1 ] |
32 ## @end group | |
33 ## @end example | |
3426 | 34 ## |
3301 | 35 ## The function clock is more accurate on systems that have the |
36 ## @code{gettimeofday} function. | |
13856
d490ca8ab1a5
Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
37 ## @seealso{now, date, datevec} |
3301 | 38 ## @end deftypefn |
1183 | 39 |
2314 | 40 ## Author: jwe |
41 | |
2311 | 42 function retval = clock () |
1183 | 43 |
44 tm = localtime (time ()); | |
45 | |
46 retval = zeros (1, 6); | |
47 | |
1374 | 48 retval(1) = tm.year + 1900; |
49 retval(2) = tm.mon + 1; | |
50 retval(3) = tm.mday; | |
51 retval(4) = tm.hour; | |
52 retval(5) = tm.min; | |
53 retval(6) = tm.sec + tm.usec / 1e6; | |
1183 | 54 |
55 endfunction | |
7411 | 56 |
57 %!test | |
58 %! t1 = clock; | |
59 %! 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
|
60 %! assert (etime (t1, t2) < 1); |
7411 | 61 |