.- .
基于指定时间基准,将第一个参数指向的间隔设置为当前日历时间。
语法
int timespec_get(
struct timespec* const time_spec,
int const base
);
int _timespec32_get(
struct _timespec32* const time_spec,
int const base
);
int _timespec64_get(
struct _timespec64* const time_spec,
int const base
);
参数
time_spec
设置为自时期开始以来的时间(以秒和纳秒为单位)的结构的指针。
base
一个特定于实现的非零值,指定时间基准。
返回值
如果成功,则值为 base
,否则它返回零。
备注
timespec_get
函数设置 time_spec
参数指向的结构中的当前时间。 此结构的所有版本都具有两个成员,即 tv_sec
和 tv_nsec
。 tv_sec
值设置为自 tv_nsec
指定的时期开始以来的整秒数, base
设置为开始以来的整纳秒数(按系统时钟分辨率进行舍入)。
Microsoft 专用
这些函数仅支持 TIME_UTC
作为 base
值。 TIME_UTC
将 time_spec
值设置为自时期开始(协调世界时 (UTC) 的 1970 年 1 月 1 日午夜)以来的秒数和纳秒数。 在 _timespec32
中, tv_sec
是 __time32_t
值。 在 _timespec64
中, tv_sec
是 __time64_t
值。 在 timespec
中, tv_sec
是 time_t
类型,其长度为 32 位或 64 位,具体取决于是否定义预处理器宏 _USE_32BIT_TIME_T。 timespec_get
函数是内联函数,如果定义了 _USE_32BIT_TIME_T
,将调用 _timespec32_get
;否则调用 _timespec64_get
。
End Microsoft Specific
默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态。
要求
例程 | 必需的标头 |
---|---|
.- . | C: <time.h>、C++: <ctime> 或 <time.h> |
有关兼容性的详细信息,请参阅 兼容性。
另请参阅
工时管理
%>
%>
.- .
.- .
.- .
.- .
.- .
.- .