加入收藏
举报
02-14 20:02
#0
文件名称:
TIME-SYS.md
所在目录:
Openharmony v1.0 / docs / api / api-SmartVision-Devices
文件大小:
17.91 KB
下载地址:
fenwii/OpenHarmony
   
免责声明:本网站仅提供指向 GitHub 上的文件的链接,所有文件的版权归原作者所有,本网站不对文件内容的合法性、准确性或安全性承担任何责任。
文本预览:
# TIME-SYS
## **Overview**
Provides time-related structures and functions.
**Since:**
1.0
**Version:**
1.0
## **Summary**
## Files









File Name


Description


time.h


Provides structures and functions related to the system time.



## Data Structures


















Data Structure Name


Description


timeval


Describes a period of time, accurate to microseconds.


timespec


Describes a period of time, accurate to nanoseconds.


itimerval


Describes a timer.


timezone


Describes a time zone.



## Macros









Macro Name and Value


Description


ITIMER_REAL    0


Defines the timer that runs in real time.



## Functions


















Function Name


Description


gettimeofday (struct timeval *__restrict value, void *__restrict ovalue)


int 


Obtains the system time and time zone.


getitimer (int w, struct itimerval *old)


int 


Obtains the value of an intermittent timer.


setitimer (int w, const struct itimerval *__restrict value, struct itimerval *__restrict ovalue)


int 


Sets the value for a timer.


settimeofday (const struct timeval *tv, const struct timezone *tz)


int 


Sets the system time and time zone.



## **Details**
## **Function Documentation**
## getitimer\(\)
```
int getitimer (int w, struct [itimerval](itimerval.md) * old )
```
**Description:**
Obtains the value of an intermittent timer.
**Parameters:**












Name


Description


w Indicates the timer type. Only ITIMER_REAL is supported.
old Indicates the pointer to the timer value.

**Returns:**
Returns **0** if the operation is successful; returns **-1** and sets **errno** to a value in the following table if the operation fails.









errno


Description


EINVAL


Incorrect input or timer type.



## gettimeofday\(\)
```
int gettimeofday (struct [timeval](timeval.md) *__restrict value, void *__restrict ovalue )
```
**Description:**
Obtains the system time and time zone.
**Parameters:**












Name


Description


value Indicates the pointer to the timeval structure that contains the time.
ovalue This parameter is used for compatibility only.

**Attention:**
Currently, there is no time zone structure. The return value of **ovalue** is empty.
**Returns:**
Returns **0** if the operation is successful; returns **-1** and sets **errno** to a value in the following table if the operation fails.









errno


Description


EINVAL


Incorrect input.



## setitimer\(\)
```
int setitimer (int w, const struct [itimerval](itimerval.md) *__restrict value, struct [itimerval](itimerval.md) *__restrict ovalue )
```
**Description:**
Sets the value for a timer.
**Parameters:**















Name


Description


w Indicates the timer type. Currently, only ITIMER_REAL is supported.
value Indicates the pointer to the timer value to set.
ovalue Indicates the pointer to the original timer value before the current setting, which can be NULL.

**Returns:**
Returns **0** if the operation is successful; returns **-1** and sets **errno** to a value in the following table if the operation fails.









errno


Description


EINVAL


Incorrect input or timer type.



## settimeofday\(\)
```
int settimeofday (const struct [timeval](timeval.md) * tv, const struct [timezone](timezone.md) * tz )
```
**Description:**
Sets the system time and time zone.
**Parameters:**












Name


Description


tv Indicates the pointer to the time to set.
tz Indicates the pointer to the time zone to set. This parameter is not used yet.

**Attention:**
**tz** is invalid. The time is set internally using **clock\_settime**.
**Returns:**
Returns **0** if the operation is successful; returns **-1** and sets **errno** to a value in the following table if the operation fails.









errno


Description


EINVAL


Incorrect input.


点赞 回复
回帖
支持markdown部分语法 ?