1 Star 0 Fork 5.4K

How / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
time-h.md 24.93 KB
一键复制 编辑 原始数据 按行查看 历史
[yang] 提交于 2020-12-12 14:19 . Description: update docs 20201212

time.h

Overview

Related Modules:

TIME

Description:

Provides time-related structures and functions.

You can perform time-related management operations, including obtaining and setting broken-down time and system ticks, and manipulating timers.

Since:

1.0

Version:

1.0

Summary

Data Structures

Data Structure Name

Description

tm

Describes date and time information.

itimerspec

Sets a timer.

Macros

Macro Name and Value

Description

CLOCK_REALTIME 0

Defines a real-time clock.

CLOCK_MONOTONIC 1

Defines a monotonic clock.

CLOCK_MONOTONIC_RAW 4

Defines a raw hardware-based monotonic clock.

CLOCK_REALTIME_COARSE 5

Defines a low-precision real-time clock.

CLOCK_MONOTONIC_COARSE 6

Defines a low-precision monotonic clock.

Functions

Function

Description

time (time_t *t)

time_t

Obtains the time.

difftime (time_t time1, time_t time2)

double

Calculates the difference between two times, in seconds.

mktime (struct tm *tm)

time_t

Converts the broken-down time in the tm structure into seconds.

strftime (char *restrict s, size_t n, const char *restrict f, const struct tm *restrict tm)

size_t

Converts the broken-down time in the tm structure to a string in the required format.

gmtime (const time_t *t)

struct tm *

Converts the number of seconds to the UTC time in the tm structure.

localtime (const time_t *t)

struct tm *

Converts the number of seconds to the local time in the tm structure.

asctime (const struct tm *tm)

char *

Converts the broken-down time in the tm structure into a string.

ctime (const time_t *timep)

char *

Converts the date and time into a string.

strftime_l (char *__restrict s, size_t n, const char *__restrict f, const struct tm *__restrict tm, locale_t loc)

size_t

Converts the broken-down time in the tm structure to a string in a specified programming language and format.

gmtime_r (const time_t *__restrict t, struct tm *__restrict tm)

struct tm *

Converts the number of seconds to the UTC time in the tm structure. (This function is reentrant.)

localtime_r (const time_t *__restrict t, struct tm *__restrict tm)

struct tm *

Converts the number of seconds to the local time in the tm structure. (This function is reentrant.)

asctime_r (const struct tm *__restrict tm, char *__restrict buf)

char *

Converts the broken-down time in the tm structure into a string. (This function is reentrant.)

ctime_r (const time_t *t, char *buf)

char *

Converts the date and time into a string. (This function is reentrant.)

nanosleep (const struct timespec *tspec1, struct timespec *tspec2)

int

Pauses the current thread until a specified time arrives.

clock_getres (clockid_t id, struct timespec *tspec)

int

Obtains the precision of a clock.

clock_gettime (clockid_t id, struct timespec *tspec)

int

Obtains the time of a clock.

clock_settime (clockid_t id, const struct timespec *tspec)

int

Sets the time for a clock.

clock_nanosleep (clockid_t id, int flag, const struct timespec *tspec1, struct timespec *tspec2)

int

Pauses the current thread until a specified time of a clock arrives.

timer_create (clockid_t id, struct sigevent *__restrict evp, timer_t *__restrict t)

int

Creates a timer for the process.

timer_delete (timer_t t)

int

Deletes a timer for the process.

timer_settime (timer_t t, int flags, const struct itimerspec *__restrict val, struct itimerspec *__restrict old)

int

Sets a timer for the process.

timer_gettime (timer_t t, struct itimerspec *tspec)

int

Obtains a timer of the process.

timer_getoverrun (timer_t t)

int

Obtains the number of times that a timer overruns.

strptime (const char *s, const char *format, struct tm *tm)

char *

Converts a time string to the broken-down time in the tm structure.

getdate (const char *buf)

struct tm *

Converts a time string to the broken-down time in the tm structure.

stime (const time_t *t)

int

Sets the system time.

timegm (struct tm *tm)

time_t

Converts the broken-down time in the tm structure to the number of seconds.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mike-mei/docs.git
git@gitee.com:mike-mei/docs.git
mike-mei
docs
docs
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891