Files
2025-10-25 03:02:53 +03:00

39 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[ctime.syn]
# 30 Time library [[time]](./#time)
## 30.15 Header <ctime> synopsis [ctime.syn]
[🔗](#header:%3cctime%3e)
#define __STDC_VERSION_TIME_H__ 202311L#define NULL *see [[support.types.nullptr]](support.types.nullptr "17.2.3Null pointers")*#define CLOCKS_PER_SEC *see below*#define TIME_UTC *see below*#define TIME_MONOTONIC *see below* // optional#define TIME_ACTIVE *see below* // optional#define TIME_THREAD_ACTIVE *see below* // optionalnamespace std {using size_t = *see [[support.types.layout]](support.types.layout "17.2.4Sizes, alignments, and offsets")*; using clock_t = *see below*; using time_t = *see below*; struct timespec; struct tm;
clock_t clock(); double difftime(time_t time1, time_t time0);
time_t mktime(tm* timeptr);
time_t timegm(tm* timeptr);
time_t time(time_t* timer); int timespec_get(timespec* ts, int base); int timespec_getres(timespec* ts, int base);
tm* gmtime(const time_t* timer);
tm* gmtime_r(const time_t* timer, tm* buf);
tm* localtime(const time_t* timer);
tm* localtime_r(const time_t* timer, tm* buf);
size_t strftime(char* s, size_t maxsize, const char* format, const tm* timeptr);}
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L11641)
The contents of the header [<ctime>](#header:%3cctime%3e "30.15Header <ctime> synopsis[ctime.syn]") are the same as the C standard library header [<time.h>](support.c.headers.general#header:%3ctime.h%3e "17.15.1General[support.c.headers.general]")[.](#1.sentence-1)[254](#footnote-254 "strftime supports the C conversion specifiers C, D, e, F, g, G, h, r, R, t, T, u, V, and z, and the modifiers E and O.")
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L11650)
The functions gmtime andlocaltime are not required to avoid data
races ([[res.on.data.races]](res.on.data.races "16.4.6.10Data race avoidance"))[.](#2.sentence-1)
See also: ISO/IEC 9899:2024, 7.29
[254)](#footnote-254)[254)](#footnoteref-254)
strftime supports the C conversion specifiersC, D, e, F, g, G, h,r, R, t, T, u, V, andz, and the modifiers E and O[.](#footnote-254.sentence-1)