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