## Overview

The functions below can be used to tell the current clock time and the current system up time. It is not recommended to call these functions inside of a kernel.

## Summary

|                                                                   Types                                                                    ||
|-------------------------------------------------------------------------------------------------------------|-------------------------------|
| [rs_time_t](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rs_time_t) | Seconds since January 1, 1970 |
| [rs_tm](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rs_tm)         | Date and time structure       |

|                                                                      Functions                                                                       ||
|-----------------------------------------------------------------------------------------------------------------------|-------------------------------|
| [rsGetDt](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rsGetDt)               | Elapsed time since last call  |
| [rsLocaltime](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rsLocaltime)       | Convert to local time         |
| [rsTime](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rsTime)                 | Seconds since January 1, 1970 |
| [rsUptimeMillis](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rsUptimeMillis) | System uptime in milliseconds |
| [rsUptimeNanos](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rsUptimeNanos)   | System uptime in nanoseconds  |

## Types

#### rs_time_t: Seconds since January 1, 1970

A typedef of: int When compiling for 32 bits.

A typedef of: long When compiling for 64 bits.

Calendar time interpreted as seconds elapsed since the Epoch (00:00:00 on January 1, 1970, Coordinated Universal Time (UTC)).  

#### rs_tm: Date and time structure

A structure with the following fields:

|  int tm_sec  |                                        Seconds after the minute. This ranges from 0 to 59, but possibly up to 60 for leap seconds.                                         |
|  int tm_min  |                                                             Minutes after the hour. This ranges from 0 to 59.                                                              |
| int tm_hour  |                                                               Hours past midnight. This ranges from 0 to 23.                                                               |
| int tm_mday  |                                                                Day of the month. This ranges from 1 to 31.                                                                 |
|  int tm_mon  |                                                              Months since January. This ranges from 0 to 11.                                                               |
| int tm_year  |                                                                             Years since 1900.                                                                              |
| int tm_wday  |                                                                Days since Sunday. This ranges from 0 to 6.                                                                 |
| int tm_yday  |                                                              Days since January 1. This ranges from 0 to 365.                                                              |
| int tm_isdst | 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. |
|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

<br />

Data structure for broken-down time components.

## Functions

#### rsGetDt: Elapsed time since last call

|------------------|---|
| float rsGetDt(); |   |

##### Returns

|------------------|
| Time in seconds. |

Returns the time in seconds since this function was last called in this script.  

#### rsLocaltime: Convert to local time

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [rs_tm](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rs_tm)\* rsLocaltime([rs_tm](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rs_tm)\* local, const[rs_time_t](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rs_time_t)\* timer); |   |

##### Parameters

| local | Pointer to time structure where the local time will be stored. |
| timer |    Input time as a number of seconds since January 1, 1970.    |
|-------|----------------------------------------------------------------|

##### Returns

|-------------------------------------------------------------------------------|
| Pointer to the output local time, i.e. the same value as the parameter local. |

Converts the time specified by timer into a[rs_tm](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rs_tm)structure that provides year, month, hour, etc. This value is stored at \*local.

This functions returns the same pointer that is passed as first argument. If the local parameter is NULL, this function does nothing and returns NULL.  

#### rsTime: Seconds since January 1, 1970

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [rs_time_t](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rs_time_t)rsTime([rs_time_t](https://developer.android.com/guide/topics/renderscript/reference/rs_time#android_rs:rs_time_t)\* timer); |   |

##### Parameters

| timer | Location to also store the returned calendar time. |
|-------|----------------------------------------------------|

##### Returns

|--------------------------------------------------|
| Seconds since the Epoch, -1 if there's an error. |

Returns the number of seconds since the Epoch (00:00:00 UTC, January 1, 1970).

If timer is non-NULL, the result is also stored in the memory pointed to by this variable.  

#### rsUptimeMillis: System uptime in milliseconds

|---------------------------------------------------------------------------------------------------------------------------------|---|
| [int64_t](https://developer.android.com/guide/topics/renderscript/reference/rs_value_types#android_rs:int64_t)rsUptimeMillis(); |   |

##### Returns

|-------------------------|
| Uptime in milliseconds. |

Returns the current system clock (uptime) in milliseconds.  

#### rsUptimeNanos: System uptime in nanoseconds

|--------------------------------------------------------------------------------------------------------------------------------|---|
| [int64_t](https://developer.android.com/guide/topics/renderscript/reference/rs_value_types#android_rs:int64_t)rsUptimeNanos(); |   |

##### Returns

|------------------------|
| Uptime in nanoseconds. |

Returns the current system clock (uptime) in nanoseconds.

The granularity of the values return by this call may be much larger than a nanosecond.