timespec_get
、 、 _timespec32_get
_timespec64_get
使用第一個引數,依據指定的時間基礎,將間隔設定成指向目前的月曆時間。
語法
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
設定為自 Epoch 啟動後所經歷之時間 (以秒及奈秒為單位) 的結構指標。
base
非零實作的專用值,會指定時間依據。
傳回值
若成功,會傳回 base
的值,否則會傳回零。
備註
timespec_get
函式會透過 time_spec
引數,將指向的結構設為目前的時間。 此結構的所有版本皆具有 tv_sec
與 tv_nsec
兩個成員。 tv_sec
值會設為自 tv_nsec
指定之 Epoch 啟動之後所經歷的秒數 (整數),而 base
值則會設為奈秒數 (整數),並四捨五入到系統時鐘的解析度。
Microsoft 特定的
這些函式只可以 TIME_UTC
的 base
值提供支援。 TIME_UTC
會設定自 time_spec
1970 年 1 月 1 日午夜、國際標準時間 (UTC) 以來的秒數和奈秒數。 在 _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 中的全域狀態。
需求
常式 | 必要的標頭 |
---|---|
timespec_get 、 、 _timespec32_get _timespec64_get |
C: <time.h>、C++: <ctime> 或 <time.h> |
如需相容性詳細資訊,請參閱相容性。
另請參閱
時間管理
asctime
, _wasctime
asctime_s
, _wasctime_s
_ftime
、 、 _ftime32
_ftime64
gmtime
、 、 _gmtime32
_gmtime64
gmtime_s
、 、 _gmtime32_s
_gmtime64_s
localtime
、 、 _localtime32
_localtime64
localtime_s
、 、 _localtime32_s
_localtime64_s
time
、 、 _time32
_time64
_utime
、、_utime32
_utime64
、_wutime
、、_wutime32
、_wutime64