time.h(0P)
π time.h β bestie edition π
okay so. we're in the POSIX Programmer's Manual, bestie. this is the time.h(0P) page. i folded the manual name in right here so you don't have to scroll, you're welcome π«Ά
πΈ PROLOG πΈ
this manual page is part of the POSIX Programmer's Manual. heads up tho:
the Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the actual Linux tea β), or honestly the interface may not be implemented on Linux at all. no cap.
β¨ NAME β¨
time.h β time types. that's it. that's the whole name. iconic.
π SYNOPSIS π
#include <time.h>
yes bestie just one line. the way that it's just one include?? π
π DESCRIPTION π
so some of the functionality on this reference page extends the ISO C standard. if you want those extra symbols visible in this header, your app shall define the appropriate feature test macro β see the System Interfaces volume of POSIX.1β2017, Section 2.2, The Compilation Environment. iykyk π₯
the <time.h> header shall define the clock_t, size_t, time_t types as described in <sys/types.h>.
the <time.h> header shall define the clockid_t and timer_t types as described in <sys/types.h>.
the <time.h> header shall define the locale_t type as described in <locale.h>.
the <time.h> header shall define the pid_t type as described in <sys/types.h>.
the tag sigevent shall be declared as naming an incomplete structure type, and its contents are described over in the <signal.h> header. (mysterious. love that for it. π)
the <time.h> header shall declare the tm structure, which shall include at least these members:
int tm_sec Seconds [0,60].
int tm_min Minutes [0,59].
int tm_hour Hour [0,23].
int tm_mday Day of month [1,31].
int tm_mon Month of year [0,11].
int tm_year Years since 1900.
int tm_wday Day of week [0,6] (Sunday =0).
int tm_yday Day of year [0,365].
int tm_isdst Daylight Savings flag.
and the value of tm_isdst shall be:
- positive if Daylight Savings Time is in effect
- 0 if Daylight Savings Time is not in effect
- negative if the information is not available
the <time.h> header shall declare the timespec structure, which shall include at least:
time_t tv_sec Seconds.
long tv_nsec Nanoseconds.
and the <time.h> header shall also declare the itimerspec structure, which shall include at least:
struct timespec it_interval Timer period.
struct timespec it_value Timer expiration.
π the macros π
the <time.h> header shall define the following macros:
NULLβ as described in<stddef.h>. the classic. the blueprint. πCLOCKS_PER_SECβ a number used to convert the value returned by theclock()function into seconds. the value shall be an expression with typeclock_t. the value ofCLOCKS_PER_SECshall be 1 million on XSI-conformant systems. however, it may be variable on other systems, and it should not be assumed thatCLOCKS_PER_SECis a compile-time constant. π«
π the symbolic constants (clockid_t edition) π
the <time.h> header shall define the following symbolic constants. the values shall have a type that is assignment-compatible with clockid_t.
CLOCK_MONOTONICβ the identifier for the system-wide monotonic clock. it's defined as a clock measuring real time, whose value cannot be set viaclock_settime(), and which cannot have negative clock jumps. the maximum possible clock jump shall be implementation-defined.CLOCK_PROCESS_CPUTIME_IDβ the identifier of the CPU-time clock associated with the process making aclock()ortimer*()function call.CLOCK_REALTIMEβ the identifier of the system-wide clock measuring real time.CLOCK_THREAD_CPUTIME_IDβ the identifier of the CPU-time clock associated with the thread making aclock()ortimer*()function call.
π¦ one (1) more symbolic constant π¦
the <time.h> header shall define the following symbolic constant:
TIMER_ABSTIMEβ flag indicating time is absolute. for functions taking timer objects, this refers to the clock associated with the timer.
π getdate_err moment π
the <time.h> header shall provide a declaration or definition for getdate_err. the getdate_err symbol shall expand to an expression of type int.
okay so here's the drama: it is unspecified whether getdate_err is a macro or an identifier declared with external linkage, and whether or not it is a modifiable lvalue. and fr fr β if a macro definition is suppressed in order to access an actual object, or a program defines an identifier with the name getdate_err, the behavior is undefined. β οΈ so like... don't. π
π§ the functions π§
the following shall be declared as functions and may also be defined as macros. function prototypes shall be provided.
char *asctime(const struct tm *);
char *asctime_r(const struct tm *restrict, char *restrict);
clock_t clock(void);
int clock_getcpuclockid(pid_t, clockid_t *);
int clock_getres(clockid_t, struct timespec *);
int clock_gettime(clockid_t, struct timespec *);
int clock_nanosleep(clockid_t, int, const struct timespec *,
struct timespec *);
int clock_settime(clockid_t, const struct timespec *);
char *ctime(const time_t *);
char *ctime_r(const time_t *, char *);
double difftime(time_t, time_t);
struct tm *getdate(const char *);
struct tm *gmtime(const time_t *);
struct tm *gmtime_r(const time_t *restrict, struct tm *restrict);
struct tm *localtime(const time_t *);
struct tm *localtime_r(const time_t *restrict, struct tm *restrict);
time_t mktime(struct tm *);
int nanosleep(const struct timespec *, struct timespec *);
size_t strftime(char *restrict, size_t, const char *restrict,
const struct tm *restrict);
size_t strftime_l(char *restrict, size_t, const char *restrict,
const struct tm *restrict, locale_t);
char *strptime(const char *restrict, const char *restrict,
struct tm *restrict);
time_t time(time_t *);
int timer_create(clockid_t, struct sigevent *restrict,
timer_t *restrict);
int timer_delete(timer_t);
int timer_getoverrun(timer_t);
int timer_gettime(timer_t, struct itimerspec *);
int timer_settime(timer_t, int, const struct itimerspec *restrict,
struct itimerspec *restrict);
void tzset(void);
like, that's a LOT of functions. we ate. π
π the variables π
the <time.h> header shall declare the following as variables:
extern int daylight;
extern long timezone;
extern char *tzname[];
also, inclusion of the <time.h> header may make visible all symbols from the <signal.h> header. surprise! β¨
the following sections are informative. (so like, they're the commentary track, not the rules π)
πΈ APPLICATION USAGE πΈ
- the range
[0,60]fortm_secallows for the occasional leap second. β±οΈ tm_yearis a signed value; therefore, years before 1900 may be represented. so yes bestie you CAN go back in time. π°οΈ- to obtain the number of clock ticks per second returned by the
times()function, applications should callsysconf(_SC_CLK_TCK).
π RATIONALE π
the range [0,60] seconds allows for positive or negative leap seconds. the formal definition of UTC does not permit double leap seconds, so all mention of double leap seconds has been removed, and the range shortened from the former [0,61] seconds seen in earlier versions of this standard. glow-down for the double leap second honestly. π
π FUTURE DIRECTIONS π
None. that's it. nothing on the horizon. the future is quiet, bestie. π
π¦ SEE ALSO π¦
the headers:
<locale.h><signal.h><stddef.h><sys_types.h>
and from the System Interfaces volume of POSIX.1β2017, Section 2.2, The Compilation Environment, plus: asctime(), clock(), clock_getcpuclockid(), clock_getres(), clock_nanosleep(), ctime(), difftime(), getdate(), gmtime(), localtime(), mktime(), mq_receive(), mq_send(), nanosleep(), pthread_getcpuclockid(), pthread_mutex_timedlock(), pthread_rwlock_timedrdlock(), pthread_rwlock_timedwrlock(), sem_timedwait(), strftime(), strptime(), sysconf(), time(), timer_create(), timer_delete(), timer_getoverrun(), tzset(), utime().
a whole reading list. go off. π
π COPYRIGHT π
portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.
in the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. the original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. to report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
okay and finally, the little sign-off at the bottom of the page: this one's from IEEE/The Open Group, dated 2017, and it's the time.h(0P) page. that's the whole thing bestie, you're a time.h expert now, periodt. πβ¨ππ¦
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms