Tipos y funciones de tiempo de RenderScript
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Descripción general
Las siguientes funciones se pueden usar para indicar la hora actual del reloj y la hora actual del sistema. No se recomienda llamar a estas funciones dentro de un kernel.
Resumen
Tipos |
rs_time_t
|
Segundos desde el 1 de enero de 1970
|
rs_tm
|
Estructura de fecha y hora
|
Tipos
rs_time_t
: Segundos desde el 1 de enero de 1970
Un typedef de: int Cuando compilas para 32 bits
Un typedef de: long. Al compilar para 64 bits
Es la hora del calendario interpretada como los segundos transcurridos desde la época (00:00:00 del 1 de enero de 1970, hora universal coordinada [UTC]).
rs_tm
: Estructura de fecha y hora
Una estructura con los siguientes campos:
int tm_s | Segundos después del minuto. Puede variar de 0 a 59, pero posiblemente hasta 60 para los segundos bisiestos. |
int tm_min | Minutos después de la hora. Puede variar de 0 a 59. |
int_tm_hora | Horas después de la medianoche. Puede variar de 0 a 23. |
int_tm_mdía | Día del mes Puede variar de 1 a 31. |
int tm_mon | Meses desde enero. Puede variar de 0 a 11. |
int_tm_year | Años desde 1900. |
int tm_wdía | Días desde el domingo. Puede variar de 0 a 6. |
int tm_ydía | Días desde el 1 de enero Puede variar de 0 a 365. |
int tm_isdst | Marca que indica si el horario de verano está vigente. El valor es positivo si está vigente, cero si no lo está y negativo si la información no está disponible. |
Estructura de datos para componentes de tiempo desglosados
Funciones
rsGetDt
: Tiempo transcurrido desde la última llamada
Muestra el tiempo en segundos transcurridos desde la última vez que se llamó a esta función en esta secuencia de comandos.
rsLocaltime
: Convertir a hora local
Parámetros
locales | Es el puntero a la estructura de hora en la que se almacenará la hora local. |
temporizador | Ingresa la hora como un número de segundos desde el 1 de enero de 1970. |
Devoluciones
Es el puntero a la hora local de salida, es decir, el mismo valor que el parámetro local. |
Convierte la hora especificada por el temporizador en una estructura rs_tm que proporciona año, mes, hora, etc. Este valor se almacena como *local.
Esta función muestra el mismo puntero que se pasa como primer argumento. Si el parámetro local es NULL, esta función no hace nada y muestra NULL.
rsTime
: segundos desde el 1 de enero de 1970
Parámetros
temporizador | Es la ubicación para almacenar también la hora del calendario que se muestra. |
Devoluciones
Segundos desde la época, -1 si hay un error. |
Muestra el número de segundos desde la época (00:00:00 UTC, 1 de enero de 1970).
Si el temporizador no es NULL, el resultado también se almacena en la memoria a la que apunta esta variable.
rsUptimeMillis
: Tiempo de actividad del sistema en milisegundos
Devoluciones
Tiempo de actividad en milisegundos. |
Muestra el reloj actual del sistema (tiempo de actividad) en milisegundos.
rsUptimeNanos
: Tiempo de actividad del sistema en nanosegundos
Devoluciones
Es el tiempo de actividad en nanosegundos. |
Muestra el reloj actual del sistema (tiempo de actividad) en nanosegundos.
El nivel de detalle de los valores que muestra esta llamada puede ser mucho mayor que un nanosegundo.
El contenido y las muestras de código que aparecen en esta página están sujetas a las licencias que se describen en la Licencia de Contenido. Java y OpenJDK son marcas registradas de Oracle o sus afiliados.
Última actualización: 2025-07-27 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-07-27 (UTC)"],[],[],null,["# RenderScript Time Functions and Types\n\nOverview\n--------\n\nThe functions below can be used to tell the current clock time and the current\nsystem up time. It is not recommended to call these functions inside of a kernel.\n\nSummary\n-------\n\n| Types ||\n|--------------------------------------------------------------------------------|-------------------------------|\n| [rs_time_t](/guide/topics/renderscript/reference/rs_time#android_rs:rs_time_t) | Seconds since January 1, 1970 |\n| [rs_tm](/guide/topics/renderscript/reference/rs_time#android_rs:rs_tm) | Date and time structure |\n\n| Functions ||\n|------------------------------------------------------------------------------------------|-------------------------------|\n| [rsGetDt](/guide/topics/renderscript/reference/rs_time#android_rs:rsGetDt) | Elapsed time since last call |\n| [rsLocaltime](/guide/topics/renderscript/reference/rs_time#android_rs:rsLocaltime) | Convert to local time |\n| [rsTime](/guide/topics/renderscript/reference/rs_time#android_rs:rsTime) | Seconds since January 1, 1970 |\n| [rsUptimeMillis](/guide/topics/renderscript/reference/rs_time#android_rs:rsUptimeMillis) | System uptime in milliseconds |\n| [rsUptimeNanos](/guide/topics/renderscript/reference/rs_time#android_rs:rsUptimeNanos) | System uptime in nanoseconds |\n\nTypes\n-----\n\n#### rs_time_t\n: Seconds since January 1, 1970\n\nA typedef of: int When compiling for 32 bits.\n\nA typedef of: long When compiling for 64 bits.\n\nCalendar time interpreted as seconds elapsed since the Epoch (00:00:00 on\nJanuary 1, 1970, Coordinated Universal Time (UTC)). \n\n#### rs_tm\n: Date and time structure\n\nA structure with the following fields:\n\n| int tm_sec | Seconds after the minute. This ranges from 0 to 59, but possibly up to 60 for leap seconds. |\n| int tm_min | Minutes after the hour. This ranges from 0 to 59. |\n| int tm_hour | Hours past midnight. This ranges from 0 to 23. |\n| int tm_mday | Day of the month. This ranges from 1 to 31. |\n| int tm_mon | Months since January. This ranges from 0 to 11. |\n| int tm_year | Years since 1900. |\n| int tm_wday | Days since Sunday. This ranges from 0 to 6. |\n| int tm_yday | Days since January 1. This ranges from 0 to 365. |\n| 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. |\n|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n\u003cbr /\u003e\n\nData structure for broken-down time components.\n\nFunctions\n---------\n\n#### rsGetDt\n: Elapsed time since last call\n\n|------------------|---|\n| float rsGetDt(); | |\n\n##### Returns\n\n|------------------|\n| Time in seconds. |\n\nReturns the time in seconds since this function was last called in this script. \n\n#### rsLocaltime\n: Convert to local time\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [rs_tm](/guide/topics/renderscript/reference/rs_time#android_rs:rs_tm)\\* rsLocaltime([rs_tm](/guide/topics/renderscript/reference/rs_time#android_rs:rs_tm)\\* local, const [rs_time_t](/guide/topics/renderscript/reference/rs_time#android_rs:rs_time_t)\\* timer); | |\n\n##### Parameters\n\n| local | Pointer to time structure where the local time will be stored. |\n| timer | Input time as a number of seconds since January 1, 1970. |\n|-------|----------------------------------------------------------------|\n\n##### Returns\n\n|-------------------------------------------------------------------------------|\n| Pointer to the output local time, i.e. the same value as the parameter local. |\n\nConverts the time specified by timer into a [rs_tm](/guide/topics/renderscript/reference/rs_time#android_rs:rs_tm) structure that provides year, month,\nhour, etc. This value is stored at \\*local.\n\nThis functions returns the same pointer that is passed as first argument. If the\nlocal parameter is NULL, this function does nothing and returns NULL. \n\n#### rsTime\n: Seconds since January 1, 1970\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [rs_time_t](/guide/topics/renderscript/reference/rs_time#android_rs:rs_time_t) rsTime([rs_time_t](/guide/topics/renderscript/reference/rs_time#android_rs:rs_time_t)\\* timer); | |\n\n##### Parameters\n\n| timer | Location to also store the returned calendar time. |\n|-------|----------------------------------------------------|\n\n##### Returns\n\n|--------------------------------------------------|\n| Seconds since the Epoch, -1 if there's an error. |\n\nReturns the number of seconds since the Epoch (00:00:00 UTC, January 1, 1970).\n\nIf timer is non-NULL, the result is also stored in the memory pointed to by\nthis variable. \n\n#### rsUptimeMillis\n: System uptime in milliseconds\n\n|-----------------------------------------------------------------------------------------------------|---|\n| [int64_t](/guide/topics/renderscript/reference/rs_value_types#android_rs:int64_t) rsUptimeMillis(); | |\n\n##### Returns\n\n|-------------------------|\n| Uptime in milliseconds. |\n\nReturns the current system clock (uptime) in milliseconds. \n\n#### rsUptimeNanos\n: System uptime in nanoseconds\n\n|----------------------------------------------------------------------------------------------------|---|\n| [int64_t](/guide/topics/renderscript/reference/rs_value_types#android_rs:int64_t) rsUptimeNanos(); | |\n\n##### Returns\n\n|------------------------|\n| Uptime in nanoseconds. |\n\nReturns the current system clock (uptime) in nanoseconds.\n\nThe granularity of the values return by this call may be much larger than a nanosecond."]]