blob: 1e6ab9920c410d669c2ff39bbb81daefa2925161 [file] [log] [blame]
Jason Sams044e2ee2011-08-08 16:52:30 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/** @file rs_time.rsh
Stephen Hinese227f9a2013-05-29 14:48:19 -070018 * \brief RenderScript time routines
Jason Sams044e2ee2011-08-08 16:52:30 -070019 *
Stephen Hinese227f9a2013-05-29 14:48:19 -070020 * This file contains RenderScript functions relating to time and date
Stephen Hinesd5dccb82011-08-26 19:03:16 -070021 * manipulation.
Jason Sams044e2ee2011-08-08 16:52:30 -070022 */
23
Stephen Hinesca3f09c2011-01-07 15:11:30 -080024#ifndef __RS_TIME_RSH__
25#define __RS_TIME_RSH__
26
Stephen Hinesd5dccb82011-08-26 19:03:16 -070027/**
28 * Calendar time interpreted as seconds elapsed since the Epoch (00:00:00 on
29 * January 1, 1970, Coordinated Universal Time (UTC)).
30 */
Stephen Hinesca3f09c2011-01-07 15:11:30 -080031typedef int rs_time_t;
32
Stephen Hinesd5dccb82011-08-26 19:03:16 -070033/**
34 * Data structure for broken-down time components.
35 *
36 * tm_sec - Seconds after the minute. This ranges from 0 to 59, but possibly
37 * up to 60 for leap seconds.
38 * tm_min - Minutes after the hour. This ranges from 0 to 59.
39 * tm_hour - Hours past midnight. This ranges from 0 to 23.
40 * tm_mday - Day of the month. This ranges from 1 to 31.
41 * tm_mon - Months since January. This ranges from 0 to 11.
42 * tm_year - Years since 1900.
43 * tm_wday - Days since Sunday. This ranges from 0 to 6.
44 * tm_yday - Days since January 1. This ranges from 0 to 365.
45 * tm_isdst - Flag to indicate whether daylight saving time is in effect. The
46 * value is positive if it is in effect, zero if it is not, and
47 * negative if the information is not available.
48 */
Stephen Hinesca3f09c2011-01-07 15:11:30 -080049typedef struct {
Stephen Hinesd5dccb82011-08-26 19:03:16 -070050 int tm_sec; ///< seconds
51 int tm_min; ///< minutes
52 int tm_hour; ///< hours
53 int tm_mday; ///< day of the month
54 int tm_mon; ///< month
55 int tm_year; ///< year
56 int tm_wday; ///< day of the week
57 int tm_yday; ///< day of the year
58 int tm_isdst; ///< daylight savings time
Stephen Hinesca3f09c2011-01-07 15:11:30 -080059} rs_tm;
60
Stephen Hinesd5dccb82011-08-26 19:03:16 -070061/**
62 * Returns the number of seconds since the Epoch (00:00:00 UTC, January 1,
63 * 1970). If @p timer is non-NULL, the result is also stored in the memory
64 * pointed to by this variable. If an error occurs, a value of -1 is returned.
65 *
66 * @param timer Location to also store the returned calendar time.
67 *
68 * @return Seconds since the Epoch.
69 */
Stephen Hinesca3f09c2011-01-07 15:11:30 -080070extern rs_time_t __attribute__((overloadable))
71 rsTime(rs_time_t *timer);
72
Stephen Hinesd5dccb82011-08-26 19:03:16 -070073/**
74 * Converts the time specified by @p timer into broken-down time and stores it
75 * in @p local. This function also returns a pointer to @p local. If @p local
76 * is NULL, this function does nothing and returns NULL.
77 *
78 * @param local Broken-down time.
79 * @param timer Input time as calendar time.
80 *
81 * @return Pointer to broken-down time (same as input @p local).
82 */
Stephen Hinesca3f09c2011-01-07 15:11:30 -080083extern rs_tm * __attribute__((overloadable))
84 rsLocaltime(rs_tm *local, const rs_time_t *timer);
85
Stephen Hinesd5dccb82011-08-26 19:03:16 -070086/**
87 * Returns the current system clock (uptime) in milliseconds.
88 *
89 * @return Uptime in milliseconds.
90 */
Stephen Hinesca3f09c2011-01-07 15:11:30 -080091extern int64_t __attribute__((overloadable))
92 rsUptimeMillis(void);
93
Stephen Hinesd5dccb82011-08-26 19:03:16 -070094/**
95 * Returns the current system clock (uptime) in nanoseconds.
96 *
97 * @return Uptime in nanoseconds.
98 */
Stephen Hinesca3f09c2011-01-07 15:11:30 -080099extern int64_t __attribute__((overloadable))
100 rsUptimeNanos(void);
101
Stephen Hinesd5dccb82011-08-26 19:03:16 -0700102/**
103 * Returns the time in seconds since this function was last called in this
104 * script.
105 *
106 * @return Time in seconds.
107 */
Stephen Hinesca3f09c2011-01-07 15:11:30 -0800108extern float __attribute__((overloadable))
109 rsGetDt(void);
110
111#endif