1.\" 2.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for 3.\" permission to reproduce portions of its copyrighted documentation. 4.\" Original documentation from The Open Group can be obtained online at 5.\" http://www.opengroup.org/bookstore/. 6.\" 7.\" The Institute of Electrical and Electronics Engineers and The Open 8.\" Group, have given us permission to reprint portions of their 9.\" documentation. 10.\" 11.\" In the following statement, the phrase ``this text'' refers to portions 12.\" of the system documentation. 13.\" 14.\" Portions of this text are reprinted and reproduced in electronic form 15.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition, 16.\" Standard for Information Technology -- Portable Operating System 17.\" Interface (POSIX), The Open Group Base Specifications Issue 6, 18.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics 19.\" Engineers, Inc and The Open Group. In the event of any discrepancy 20.\" between these versions and the original IEEE and The Open Group 21.\" Standard, the original IEEE and The Open Group Standard is the referee 22.\" document. The original Standard can be obtained online at 23.\" http://www.opengroup.org/unix/online.html. 24.\" 25.\" This notice shall appear on any product containing this material. 26.\" 27.\" The contents of this file are subject to the terms of the 28.\" Common Development and Distribution License (the "License"). 29.\" You may not use this file except in compliance with the License. 30.\" 31.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 32.\" or http://www.opensolaris.org/os/licensing. 33.\" See the License for the specific language governing permissions 34.\" and limitations under the License. 35.\" 36.\" When distributing Covered Code, include this CDDL HEADER in each 37.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. 38.\" If applicable, add the following below this CDDL HEADER, with the 39.\" fields enclosed by brackets "[]" replaced with your own identifying 40.\" information: Portions Copyright [yyyy] [name of copyright owner] 41.\" 42.\" 43.\" Copyright (c) 2001, The IEEE and The Open Group. All Rights Reserved. 44.\" Portions Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved. 45.\" Copyright 2016 Joyent, Inc. 46.\" Copyright 2025 Oxide Computer Company 47.\" 48.Dd January 12, 2025 49.Dt TIME.H 3HEAD 50.Os 51.Sh NAME 52.Nm time.h , 53.Nm time 54.Nd time types 55.Sh SYNOPSIS 56.In time.h 57.Sh DESCRIPTION 58The 59.In time.h 60header declares the structure 61.Vt tm , 62which includes the following members: 63.Bd -literal -offset indent 64int tm_sec /* seconds [0,60] */ 65int tm_min /* minutes [0,59] */ 66int tm_hour /* hour [0,23] */ 67int tm_mday /* day of month [1,31] */ 68int tm_mon /* month of year [0,11] */ 69int tm_year /* years since 1900 */ 70int tm_wday /* day of week [0,6] (Sunday =0) */ 71int tm_yday /* day of year [0,365] */ 72int tm_isdst /* daylight savings flag */ 73.Ed 74.Pp 75The value of 76.Fa tm_isdst 77is positive if Daylight Saving Time is in effect, 0 if Daylight Saving 78Time is not in effect, and negative if the information is not available. 79.Pp 80The 81.In time.h 82header defines the following symbolic names: 83.Bl -tag -width Ds 84.It Dv CLOCK_MONOTONIC 85The identifier for the system-wide monotonic clock, which is defined as a clock 86whose value cannot be set with 87.Fn clock_settime 88and that cannot have backward clock jumps. 89The maximum possible clock jump is implementation-defined. 90See 91.Xr clock_settime 3C . 92.It Dv CLOCKS_PER_SEC 93A number used to convert the value returned by the 94.Fn clock 95function into seconds. 96See 97.Xr clock 3C . 98.It Dv CLOCK_PROCESS_CPUTIME_ID 99The identifier of the CPU-time clock associated with the process making a 100.Fn clock 101or 102.Fn timer_* 103function call. 104This clock includes both user and system CPU-time. 105.It Dv CLOCK_REALTIME 106The identifier of the system-wide realtime clock. 107.It Dv CLOCK_THREAD_CPUTIME_ID 108The identifier of the CPU-time clock associated with the thread making a 109.Fn clock 110or 111.Fn timer_* 112function call. 113This clock includes both user and system CPU-time. 114.It Dv CLOCK_VIRTUAL 115The identifier of the CPU-time clock associated with the thread making a 116.Fn clock 117or 118.Fn timer_* 119function call. 120This clock only includes user CPU-time. 121.It Dv NULL 122Null pointer constant. 123.It Dv TIMER_ABSTIME 124Flag indicating time is absolute. 125For functions taking timer objects, this refers to the clock associated 126with the timer. 127.El 128.Pp 129The 130.In time.h 131header defines the following clock constants which are used with the 132.Xr timespec_get 3C 133and 134.Xr timespec_getres 3C 135calls. 136Each one has a 137.Dv CLOCK_* 138equivalent. 139.Bl -tag -width Ds 140.It Dv TIME_UTC 141The equivalent of 142.Dv CLOCK_REALTIME . 143.It Dv TIME_MONOTONIC 144The equivalent of 145.Dv CLOCK_HIGHRES . 146.It Dv TIME_ACTIVE 147The equivalent of 148.Dv CLOCK_PROCESS_CPUTIME_ID . 149.It Dv TIME_THREAD_ACTIVE 150The equivalent of 151.Dv CLOCK_THREAD_CPUTIME_ID . 152.It Dv TIME_THREAD_ACTIVE_USR 153The equivalent of 154.Dv CLOCK_VIRTUAL . 155.El 156.Pp 157The 158.In time.h 159header declares the 160.Vt timespec 161structure, which has the following members: 162.Bd -literal -offset indent 163time_t tv_sec /* seconds */ 164long tv_nsec /* nanoseconds */ 165.Ed 166.Pp 167The 168.In time.h 169header declares the 170.Vt itimerspec 171structure, which has the following members: 172.Bd -literal -offset indent 173struct timespec it_interval /* timer period */ 174struct timespec it_value /* timer expiration */ 175.Ed 176.Pp 177The 178.Vt clock_t , 179.Vt size_t , 180.Vt time_t , 181.Vt clockid_t , 182and 183.Vt timer_t 184types are defined as described in 185.In sys/types.h . 186See 187.Xr types.h 3HEAD . 188.Pp 189Although the value of 190.Dv CLOCKS_PER_SEC 191is required to be 1 million on all standard-conforming systems, it can 192be variable on other systems, and it should not be assumed that 193.Dv CLOCKS_PER_SEC 194is a compile-time constant. 195.Pp 196The 197.In time.h 198header provides a declaration for 199.Dv getdate_err . 200.Pp 201The following are declared as variables: 202.Bd -literal -offset indent 203extern int daylight; 204extern long timezone; 205extern char *tzname[]; 206.Ed 207.Pp 208Inclusion of the 209.In time.h 210header can make visible all symbols from the 211.In signal.h 212header. 213.Sh USAGE 214The range [0,60] for 215.Fa tm_sec 216allows for the occasional leap second. 217.Pp 218.Fa tm_year 219is a signed value; therefore, years before 1900 can be represented. 220.Pp 221To obtain the number of clock ticks per second returned by the 222.Fn times 223function, applications should call 224.Fn sysconf "_SC_CLK_TCK" . 225See 226.Xr times 2 227and 228.Xr sysconf 3C . 229.Sh INTERFACE STABILITY 230.Sy Committed 231.Sh SEE ALSO 232.Xr time 2 , 233.Xr utime 2 , 234.Xr clock 3C , 235.Xr clock_settime 3C , 236.Xr ctime 3C , 237.Xr difftime 3C , 238.Xr getdate 3C , 239.Xr mktime 3C , 240.Xr nanosleep 3C , 241.Xr strftime 3C , 242.Xr strptime 3C , 243.Xr timer_create 3C , 244.Xr timer_delete 3C , 245.Xr timer_settime 3C , 246.Xr timespec_get 3C , 247.Xr types.h 3HEAD , 248.Xr attributes 7 , 249.Xr standards 7 250