| 1 | |
| 2 | <refentry id="date"> |
| 3 | <indexterm id="IndexDate"><primary>date</primary></indexterm> |
| 4 | <refentryinfo><title>Instrument Control:Time Reading</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>date</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>date</refname> |
| 11 | |
| 12 | <refpurpose> |
| 13 | Returns the number seconds since a base date. |
| 14 | </refpurpose> |
| 15 | </refnamediv> |
| 16 | |
| 17 | <refsect1> |
| 18 | <title>Description</title> |
| 19 | <para>Plugin opcode in cs_date.</para> |
| 20 | <para> |
| 21 | Returns the number seconds since a base date, using the |
| 22 | operating system's clock. The base is 1 January 1970 for Csound |
| 23 | using doubles, and 1 January 2010 for versions using floats. |
| 24 | On operating systemms with sufficient resolution the date |
| 25 | includes fractional seconds. |
| 26 | </para> |
| 27 | </refsect1> |
| 28 | |
| 29 | <refsect1> |
| 30 | <title>Syntax</title> |
| 31 | <synopsis>ir[, inano] <command>date</command></synopsis> |
| 32 | <synopsis>kr[, knano] <command>date</command></synopsis> |
| 33 | </refsect1> |
| 34 | |
| 35 | <refsect1> |
| 36 | <title>Initialization and Performance</title> |
| 37 | |
| 38 | <para> |
| 39 | <emphasis>ir</emphasis> -- value at i-time, of the system clock |
| 40 | in seconds since the start of the epoch. |
| 41 | </para> |
| 42 | <para> |
| 43 | <emphasis>kr</emphasis> -- value at k-time, of the system clock |
| 44 | in seconds since the start of the epoch. |
| 45 | </para> |
| 46 | <para> |
| 47 | <emphasis>inano</emphasis> -- value at i-time of the nanoseconds |
| 48 | since last second tick. |
| 49 | </para> |
| 50 | <para> |
| 51 | <emphasis>knano</emphasis> -- value at k-time of the nanoseconds |
| 52 | since last second tick. |
| 53 | </para> |
| 54 | |
| 55 | </refsect1> |
| 56 | <refsect1> |
| 57 | <para> |
| 58 | Note that the base date was originally 1970 but since verson |
| 59 | 5.14 it has been changed as single precission floating point |
| 60 | numbers are insufficient to indicate changes. |
| 61 | </para> |
| 62 | <para> |
| 63 | The optional answer and resolution including fractions of a |
| 64 | second introduced in version 6.07. |
| 65 | </para> |
| 66 | </refsect1> |
| 67 | |
| 68 | <refsect1> |
| 69 | <title>Examples</title> |
| 70 | <para> |
| 71 | Here is an example of the date opcode. It uses the file <ulink url="examples/date.csd"><citetitle>date.csd</citetitle></ulink>. |
| 72 | |
| 73 | <example> |
| 74 | <title>Example of the date opcode.</title> |
| 75 | |
| 76 | <xi:include href="examples-xml/date.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 77 | </example> |
| 78 | |
| 79 | Its output should include lines like this: |
| 80 | <screen> |
| 81 | instr 1: ii = 1447337826.778 |
| 82 | instr 1: ij = 778279830.000 |
| 83 | Thu Nov 12 14:17:07 2015 |
| 84 | Thu Nov 12 14:17:06 2015 |
| 85 | Thu Jan 1 01:00:01 1970 |
| 86 | </screen> |
| 87 | </para> |
| 88 | </refsect1> |
| 89 | |
| 90 | <refsect1> |
| 91 | <title>See also</title> |
| 92 | <para><link linkend="ControlTimeread"><citetitle>Time Reading</citetitle></link></para> |
| 93 | </refsect1> |
| 94 | |
| 95 | <refsect1> |
| 96 | <title>Credits</title> |
| 97 | <para> |
| 98 | <simplelist> |
| 99 | <member>Author: &namejohn;</member> |
| 100 | <member>University of Bath/Codemist Ltd.</member> |
| 101 | <member>Bath, UK</member> |
| 102 | <member>December 2006</member> |
| 103 | </simplelist> |
| 104 | </para> |
| 105 | |
| 106 | <para>New in Csound version 5.05</para> |
| 107 | <para>Changed in Csound version 5.14</para> |
| 108 | </refsect1> |
| 109 | </refentry> |