tm - broken-down time
Contents
Description
Describes time, broken down into distinct components.
tm_isdst describes whether daylight saving time is in effect at the time described. The value is
positive if daylight saving time is in effect, zero if it is not, and negative if the information is not
available.
tm_gmtoff is the difference, in seconds, of the timezone represented by this broken-down time and UTC
(this is the additive inverse of timezone(3)).
tm_zone is the equivalent of tzname(3) for the timezone represented by this broken-down time.
History
C89, POSIX.1-1988.
tm_gmtoff and tm_zone originate from 4.3BSD-Tahoe (where tm_zone is a char*), and were first
standardized in POSIX.1-2024.
Library
Standard C library (libc)
Name
tm - broken-down time
Notes
tm_sec can represent a leap second with the value 60.
See Also
ctime(3), strftime(3), strptime(3), time(7) Linux man-pages 6.9.1 2024-06-12 tm(3type)
Standards
C23, POSIX.1-2024.
Synopsis
#include<time.h>structtm{inttm_sec; /* Seconds [0, 60] */ inttm_min; /* Minutes [0, 59] */ inttm_hour; /* Hour [0, 23] */ inttm_mday; /* Day of the month [1, 31] */ inttm_mon; /* Month [0, 11] (January = 0) */ inttm_year; /* Year minus 1900 */ inttm_wday; /* Day of the week [0, 6] (Sunday = 0) */ inttm_yday; /* Day of the year [0, 365] (Jan/01 = 0) */ inttm_isdst; /* Daylight savings flag */ longtm_gmtoff; /* Seconds East of UTC */ constchar*tm_zone; /* Timezone abbreviation */ }; Feature Test Macro Requirements for glibc (see feature_test_macros(7)): tm_gmtoff, tm_zone: Since glibc 2.20: _DEFAULT_SOURCE glibc 2.20 and earlier: _BSD_SOURCE
Versions
In C90, tm_sec could represent values in the range [0, 61], which could represent a double leap second.
UTC doesn't permit double leap seconds, so it was limited to 60 in C99.
timezone(3), as a variable, is an XSI extension: some systems provide the V7-compatible timezone(3)
function. The tm_gmtoff field provides an alternative (with the opposite sign) for those systems.
tm_zone points to static storage and may be overridden on subsequent calls to localtime(3) and similar
functions (however, this never happens under glibc).
