1page.title=RenderScript Time Functions and Types
2
3@jd:body
4
5<div class='renderscript'>
6<h2>Overview</h2>
7<p> The functions below can be used to tell the current clock time and the current
8system up time.  It is not recommended to call these functions inside of a kernel.
9</p>
10<h2>Summary</h2>
11<table class='jd-sumtable'><tbody>
12  <tr><th colspan='2'>Types</th></tr>
13  <tr class='alt-color api apilevel-1'>
14    <td class='jd-linkcol'>
15      <a href='rs_time.html#android_rs:rs_time_t'>rs_time_t</a>
16    </td>
17    <td class='jd-descrcol' width='100%'>
18      Seconds since January 1, 1970
19    </td>
20  </tr>
21  <tr class='alt-color api apilevel-1'>
22    <td class='jd-linkcol'>
23      <a href='rs_time.html#android_rs:rs_tm'>rs_tm</a>
24    </td>
25    <td class='jd-descrcol' width='100%'>
26      Date and time structure
27    </td>
28  </tr>
29</tbody></table>
30<table class='jd-sumtable'><tbody>
31  <tr><th colspan='2'>Functions</th></tr>
32  <tr class='alt-color api apilevel-1'>
33    <td class='jd-linkcol'>
34      <a href='rs_time.html#android_rs:rsGetDt'>rsGetDt</a>
35    </td>
36    <td class='jd-descrcol' width='100%'>
37      Elapsed time since last call
38    </td>
39  </tr>
40  <tr class='alt-color api apilevel-1'>
41    <td class='jd-linkcol'>
42      <a href='rs_time.html#android_rs:rsLocaltime'>rsLocaltime</a>
43    </td>
44    <td class='jd-descrcol' width='100%'>
45      Convert to local time
46    </td>
47  </tr>
48  <tr class='alt-color api apilevel-1'>
49    <td class='jd-linkcol'>
50      <a href='rs_time.html#android_rs:rsTime'>rsTime</a>
51    </td>
52    <td class='jd-descrcol' width='100%'>
53      Seconds since January 1, 1970
54    </td>
55  </tr>
56  <tr class='alt-color api apilevel-1'>
57    <td class='jd-linkcol'>
58      <a href='rs_time.html#android_rs:rsUptimeMillis'>rsUptimeMillis</a>
59    </td>
60    <td class='jd-descrcol' width='100%'>
61      System uptime in milliseconds
62    </td>
63  </tr>
64  <tr class='alt-color api apilevel-1'>
65    <td class='jd-linkcol'>
66      <a href='rs_time.html#android_rs:rsUptimeNanos'>rsUptimeNanos</a>
67    </td>
68    <td class='jd-descrcol' width='100%'>
69      System uptime in nanoseconds
70    </td>
71  </tr>
72</tbody></table>
73<h2>Types</h2>
74<a name='android_rs:rs_time_t'></a>
75<div class='jd-details'>
76  <h4 class='jd-details-title'>
77    <span class='sympad'>rs_time_t</span>
78    <span class='normal'>: Seconds since January 1, 1970</span>
79  </h4>
80  <div class='jd-details-descr'>
81<p>A typedef of: int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    When compiling for 32 bits.
82</p>
83<p>A typedef of: long&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;    When compiling for 64 bits.
84</p>
85<p> Calendar time interpreted as seconds elapsed since the Epoch (00:00:00 on
86January 1, 1970, Coordinated Universal Time (UTC)).
87</p>
88  </div>
89</div>
90
91<a name='android_rs:rs_tm'></a>
92<div class='jd-details'>
93  <h4 class='jd-details-title'>
94    <span class='sympad'>rs_tm</span>
95    <span class='normal'>: Date and time structure</span>
96  </h4>
97  <div class='jd-details-descr'>
98<p>A structure with the following fields:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
99  <table class='jd-tagtable'><tbody>
100    <tr><th>int tm_sec</th><td>Seconds after the minute. This ranges from 0 to 59, but possibly up to 60 for leap seconds.</td></tr>
101    <tr><th>int tm_min</th><td>Minutes after the hour. This ranges from 0 to 59.</td></tr>
102    <tr><th>int tm_hour</th><td>Hours past midnight. This ranges from 0 to 23.</td></tr>
103    <tr><th>int tm_mday</th><td>Day of the month. This ranges from 1 to 31.</td></tr>
104    <tr><th>int tm_mon</th><td>Months since January. This ranges from 0 to 11.</td></tr>
105    <tr><th>int tm_year</th><td>Years since 1900.</td></tr>
106    <tr><th>int tm_wday</th><td>Days since Sunday. This ranges from 0 to 6.</td></tr>
107    <tr><th>int tm_yday</th><td>Days since January 1. This ranges from 0 to 365.</td></tr>
108    <tr><th>int tm_isdst</th><td>Flag to indicate whether daylight saving time is in effect. The value is positive if it is in effect, zero if it is not, and negative if the information is not available.</td></tr>
109  </tbody></table><br/>
110<p> Data structure for broken-down time components.
111</p>
112  </div>
113</div>
114
115<h2>Functions</h2>
116<a name='android_rs:rsGetDt'></a>
117<div class='jd-details'>
118  <h4 class='jd-details-title'>
119    <span class='sympad'>rsGetDt</span>
120    <span class='normal'>: Elapsed time since last call</span>
121  </h4>
122  <div class='jd-details-descr'>
123    <table class='jd-tagtable'><tbody>
124      <tr>
125        <td>float rsGetDt();
126</td>
127        <td>        </td>
128      </tr>
129    </tbody></table>
130  </div>
131  <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
132    <table class='jd-tagtable'><tbody>
133    <tr><td>Time in seconds.</td></tr>
134    </tbody></table>
135  </div>
136  <div class='jd-tagdata jd-tagdescr'>
137<p> Returns the time in seconds since this function was last called in this script.
138</p>
139  </div>
140</div>
141
142<a name='android_rs:rsLocaltime'></a>
143<div class='jd-details'>
144  <h4 class='jd-details-title'>
145    <span class='sympad'>rsLocaltime</span>
146    <span class='normal'>: Convert to local time</span>
147  </h4>
148  <div class='jd-details-descr'>
149    <table class='jd-tagtable'><tbody>
150      <tr>
151        <td><a href='rs_time.html#android_rs:rs_tm'>rs_tm</a>* rsLocaltime(<a href='rs_time.html#android_rs:rs_tm'>rs_tm</a>* local, const <a href='rs_time.html#android_rs:rs_time_t'>rs_time_t</a>* timer);
152</td>
153        <td>        </td>
154      </tr>
155    </tbody></table>
156  </div>
157  <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
158    <table class='jd-tagtable'><tbody>
159    <tr><th>local</th><td>Pointer to time structure where the local time will be stored.</td></tr>
160    <tr><th>timer</th><td>Input time as a number of seconds since January 1, 1970.</td></tr>
161    </tbody></table>
162  </div>
163  <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
164    <table class='jd-tagtable'><tbody>
165    <tr><td>Pointer to the output local time, i.e. the same value as the parameter local.</td></tr>
166    </tbody></table>
167  </div>
168  <div class='jd-tagdata jd-tagdescr'>
169<p> Converts the time specified by timer into a <a href='rs_time.html#android_rs:rs_tm'>rs_tm</a> structure that provides year, month,
170hour, etc.  This value is stored at *local.
171</p>
172
173<p> This functions returns the same pointer that is passed as first argument.  If the
174local parameter is NULL, this function does nothing and returns NULL.
175</p>
176  </div>
177</div>
178
179<a name='android_rs:rsTime'></a>
180<div class='jd-details'>
181  <h4 class='jd-details-title'>
182    <span class='sympad'>rsTime</span>
183    <span class='normal'>: Seconds since January 1, 1970</span>
184  </h4>
185  <div class='jd-details-descr'>
186    <table class='jd-tagtable'><tbody>
187      <tr>
188        <td><a href='rs_time.html#android_rs:rs_time_t'>rs_time_t</a> rsTime(<a href='rs_time.html#android_rs:rs_time_t'>rs_time_t</a>* timer);
189</td>
190        <td>        </td>
191      </tr>
192    </tbody></table>
193  </div>
194  <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
195    <table class='jd-tagtable'><tbody>
196    <tr><th>timer</th><td>Location to also store the returned calendar time.</td></tr>
197    </tbody></table>
198  </div>
199  <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
200    <table class='jd-tagtable'><tbody>
201    <tr><td>Seconds since the Epoch, -1 if there's an error.</td></tr>
202    </tbody></table>
203  </div>
204  <div class='jd-tagdata jd-tagdescr'>
205<p> Returns the number of seconds since the Epoch (00:00:00 UTC, January 1, 1970).
206</p>
207
208<p> If timer is non-NULL, the result is also stored in the memory pointed to by
209this variable.
210</p>
211  </div>
212</div>
213
214<a name='android_rs:rsUptimeMillis'></a>
215<div class='jd-details'>
216  <h4 class='jd-details-title'>
217    <span class='sympad'>rsUptimeMillis</span>
218    <span class='normal'>: System uptime in milliseconds</span>
219  </h4>
220  <div class='jd-details-descr'>
221    <table class='jd-tagtable'><tbody>
222      <tr>
223        <td><a href='rs_value_types.html#android_rs:int64_t'>int64_t</a> rsUptimeMillis();
224</td>
225        <td>        </td>
226      </tr>
227    </tbody></table>
228  </div>
229  <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
230    <table class='jd-tagtable'><tbody>
231    <tr><td>Uptime in milliseconds.</td></tr>
232    </tbody></table>
233  </div>
234  <div class='jd-tagdata jd-tagdescr'>
235<p> Returns the current system clock (uptime) in milliseconds.
236</p>
237  </div>
238</div>
239
240<a name='android_rs:rsUptimeNanos'></a>
241<div class='jd-details'>
242  <h4 class='jd-details-title'>
243    <span class='sympad'>rsUptimeNanos</span>
244    <span class='normal'>: System uptime in nanoseconds</span>
245  </h4>
246  <div class='jd-details-descr'>
247    <table class='jd-tagtable'><tbody>
248      <tr>
249        <td><a href='rs_value_types.html#android_rs:int64_t'>int64_t</a> rsUptimeNanos();
250</td>
251        <td>        </td>
252      </tr>
253    </tbody></table>
254  </div>
255  <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
256    <table class='jd-tagtable'><tbody>
257    <tr><td>Uptime in nanoseconds.</td></tr>
258    </tbody></table>
259  </div>
260  <div class='jd-tagdata jd-tagdescr'>
261<p> Returns the current system clock (uptime) in nanoseconds.
262</p>
263
264<p> The granularity of the values return by this call may be much larger than a nanosecond.
265</p>
266  </div>
267</div>
268
269</div>
270