1.\" $NetBSD: tm.3,v 1.7 2024/10/13 01:30:45 riastradh Exp $ 2.\" 3.\" Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi> 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25.\" POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd April 14, 2011 28.Dt TM 3 29.Os 30.Sh NAME 31.Nm tm 32.Nd time structure 33.Sh SYNOPSIS 34.In time.h 35.Sh DESCRIPTION 36The 37.In time.h 38header defines the 39.Vt tm 40structure that contains calendar dates and time broken down into components. 41The following standards-compliant fields are present: 42.Bl -column -offset indent \ 43"Type" "Field " "Months since January 1 " "Range " 44.It Sy Type Ta Sy Field Ta Sy Represents Ta Sy Range 45.It Vt int Ta Va tm_sec Ta Seconds Ta [0, 60] 46.It Vt int Ta Va tm_min Ta Minutes Ta [0, 59] 47.It Vt int Ta Va tm_hour Ta Hours since midnight Ta [0, 23] 48.It Vt int Ta Va tm_mday Ta Day of the month Ta [1, 31] 49.It Vt int Ta Va tm_mon Ta Months since January Ta [0, 11] 50.It Vt int Ta Va tm_year Ta Years since 1900 Ta 51.It Vt int Ta Va tm_wday Ta Days since Sunday Ta [0, 6] 52.It Vt int Ta Va tm_yday Ta Days since January 1 Ta [0, 365] 53.It Vt int Ta Va tm_isdt Ta Positive if daylight savings Ta >= 0 54.El 55.Pp 56The 57.Vt tm 58structure is used by various common library routines such as 59.Xr mktime 3 , 60.Xr localtime 3 , 61and 62.Xr strptime 3 . 63All fields described above are defined in the 64.St -p1003.1-2008 65standard. 66.Ss NetBSD Extensions 67In addition, the following NetBSD-specific fields are available: 68.Bl -column -offset indent \ 69"Type " "Field " "Months since January 1" 70.It Sy Type Ta Sy Field Ta Sy Represents 71.It Vt long Ta Va tm_gmtoff Ta Offset from UTC in seconds 72.It Vt "const char *" Ta Va tm_zone Ta Timezone abbreviation 73.El 74.Pp 75The 76.Va tm_zone 77and 78.Va tm_gmtoff 79fields exist, and are filled in by applicable library routines, 80only if arrangements to do so were made when the library containing 81these functions was created. 82There is no guarantee that these fields will continue to exist 83in this form in future releases of 84. Nx . 85.Pp 86The 87.Fa tm_gmtoff 88field denotes the offset (in seconds) of the time represented 89from UTC, with positive values indicating east 90of the Prime Meridian. 91The 92.Vt tm_zone 93field will become invalid and point to freed storage if the corresponding 94.Va "struct tm" 95was returned by 96.Xr localtime_rz 3 97and the 98.Ft "const timezone_t" 99.Fa tz 100argument has been freed by 101.Xr tzfree 3 . 102.Sh SEE ALSO 103.Xr asctime 3 , 104.Xr offtime 3 , 105.Xr timeval 3 , 106.Xr wcsftime 3 107.Sh STANDARDS 108The 109.Vt tm 110structure conforms to 111.St -p1003.1-2008 112with respect to the described standard structure members. 113