tm(3type)

πŸ’– tm(3type) β€” bestie it's the broken-down time struct πŸ’–

okay so real talk, this is page tm from section 3type, and it's literally about the lil struct that holds time all chopped up into pieces instead of one big scary number. she's an icon, she's a legend, and every localtime(3)-adjacent function is obsessed with her. let's get into it 🫢


✨ NAME ✨

tm β€” broken-down time πŸ’…

🌸 LIBRARY 🌸

Standard C library (libc) β€” the classic, the blueprint, the mothership ✨

πŸŽ€ SYNOPSIS πŸŽ€

like, here's her whole look:

#include <time.h>

struct tm {
    int         tm_sec;    /* Seconds          [0, 60] */
    int         tm_min;    /* Minutes          [0, 59] */
    int         tm_hour;   /* Hour             [0, 23] */
    int         tm_mday;   /* Day of the month [1, 31] */
    int         tm_mon;    /* Month            [0, 11]  (January = 0) */
    int         tm_year;   /* Year minus 1900 */
    int         tm_wday;   /* Day of the week  [0, 6]   (Sunday = 0) */
    int         tm_yday;   /* Day of the year  [0, 365] (Jan/01 = 0) */
    int         tm_isdst;  /* Daylight savings flag */

    /* Since POSIX.1-2024:  */
    long        tm_gmtoff; /* Seconds East of UTC */
    const char *tm_zone;   /* Timezone abbreviation */
};

πŸ¦‹ Feature Test Macro Requirements for glibc (see feature_test_macros(7)): πŸ¦‹

bestie you gotta define the right macro before you get to play with these two:

tm_gmtoff, tm_zone:

  • Since glibc 2.20: _DEFAULT_SOURCE
  • glibc 2.20 and earlier: _BSD_SOURCE
not me gatekeeping timezone fields behind a feature test macro 😭 that's just how glibc does it, no cap.

🌈 DESCRIPTION 🌈

She describes time, but broken down into distinct components β€” like, the opposite of a timestamp, she's the "explain it to me in little pieces" version. Very demure, very mindful. πŸ’œ

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. so it's giving "yes / no / idk" πŸ’€

tm_gmtoff is the difference, in seconds, of the timezone represented by this broken-down time and UTC β€” and like, important detail: this is the additive inverse of timezone(3). opposite sign, don't get it twisted fr fr.

tm_zone is the equivalent of tzname(3), but for the timezone represented by this broken-down time. same energy, different context ✨


πŸ’« VERSIONS πŸ’«

okay so back in C90, tm_sec could represent values in the range [0, 61], which could represent a double leap second. but UTC doesn't permit double leap seconds, so it got limited to 60 in C99. character development honestly πŸŽ€

timezone(3), as a variable, is an XSI extension: some systems provide the V7-compatible timezone(3) function instead. the tm_gmtoff field provides an alternative (with the opposite sign) for those systems. so if your fave system is being weird, tm_gmtoff has your back 🫢

tm_zone points to static storage and may be overridden on subsequent calls to localtime(3) and similar functions. however β€” and this is the slay β€” this never happens under glibc. so under glibc it's stable, everywhere else you gotta be careful bestie 😭

⚠️ static storage means the pointer isn't yours to keep forever. don't be out here holding onto it like it's a forever thing unless you know your libc's vibe.

πŸ‘‘ STANDARDS πŸ‘‘

C23, POSIX.1-2024. periodt. πŸ’…


⭐ HISTORY ⭐

C89, POSIX.1-1988. so she's old money, literally.

tm_gmtoff and tm_zone originate from 4.3BSD-Tahoe β€” where tm_zone is a char *, btw β€” and were first standardized in POSIX.1-2024. from BSD cult classic to international standard, we love a glow-up 🌟


πŸ’œ NOTES πŸ’œ

tm_sec can represent a leap second with the value 60. that's the whole note. short and iconic πŸŽ€


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole vibe! this was tm(3type) from Linux man-pages 6.20, dated 2025-10-29. go forth and break down some time, bestie β€” you ate πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • 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 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms