6c7f5d76f5d2e9ea214a09bebc5ce2b7cb9cfd53
[scilab.git] / scilab / modules / time / help / en_US / realtime.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) INRIA -
5  *
6  * Copyright (C) 2012 - 2016 - Scilab Enterprises
7  *
8  * This file is hereby licensed under the terms of the GNU GPL v2.0,
9  * pursuant to article 5.3.4 of the CeCILL v.2.1.
10  * This file was originally licensed under the terms of the CeCILL v2.1,
11  * and continues to be available under such terms.
12  * For more information, see the COPYING file which you should have received
13  * along with this program.
14  *
15  -->
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="realtime">
17     <refnamediv xml:id="realtimeinit">
18         <refname>realtimeinit</refname>
19         <refpurpose>set  time unit</refpurpose>
20     </refnamediv>
21     <refnamediv>
22         <refname>realtime</refname>
23         <refpurpose>set  dates origin or waits until date</refpurpose>
24     </refnamediv>
25     <refsynopsisdiv>
26         <title>Syntax</title>
27         <synopsis>realtimeinit(time_unit)
28             realtime(t)
29         </synopsis>
30     </refsynopsisdiv>
31     <refsection>
32         <title>Arguments</title>
33         <variablelist>
34             <varlistentry>
35                 <term>time_unit</term>
36                 <listitem>
37                     <para>
38                         a real number. The number of seconds associated to the <literal>realtime</literal> argument
39                     </para>
40                 </listitem>
41             </varlistentry>
42             <varlistentry>
43                 <term>t</term>
44                 <listitem>
45                     <para>a real number.  A date</para>
46                 </listitem>
47             </varlistentry>
48         </variablelist>
49     </refsection>
50     <refsection>
51         <title>Description</title>
52         <para>   These two functions can be used to handle real time into Scilab.</para>
53         <para>
54             <literal>realtimeinit(time_unit)</literal>  defines the time unit
55             associated to the <literal>realtime</literal> argument <literal>t</literal>
56         </para>
57         <para>
58             first call to <literal>realtime(t0)</literal> sets current date to
59             (<literal>t0</literal>).
60             subsequent calls to <literal>realtime(t)</literal> wait till date <literal>t</literal> is
61             reached.
62         </para>
63     </refsection>
64     <refsection>
65         <title>Examples</title>
66         <programlisting role="example"><![CDATA[
67 realtimeinit(1/2);//sets time unit to half a second
68 realtime(0);//sets current date to 0
69 for k=1:10
70   realtime(k);
71   mprintf('current time is '+string(k/2)+'sec .\r\n');
72 end
73
74 //next instruction outputs a dot each 2 seconds
75 realtimeinit(2);
76 realtime(0);
77 for k=1:10
78   realtime(k);
79   mprintf('.\r\n');
80 end
81
82 realtimeinit(1);
83 realtime(0);
84 dt=getdate('s');
85 realtime(10);
86 getdate('s')-dt
87  ]]></programlisting>
88     </refsection>
89     <programlisting role="example"><![CDATA[
90 realtimeinit(1);
91 realtime(0);
92 t1 = now()
93 datevec(t1)
94 realtime(10);
95 t1 = now()
96 datevec(t1)
97  ]]></programlisting>
98
99     <refsection role="see also">
100         <title>See also</title>
101         <simplelist type="inline">
102             <member>
103                 <link linkend="getdate">getdate</link>
104             </member>
105         </simplelist>
106     </refsection>
107 </refentry>