CLOCK(9)
β¨ CLOCK(9) β handy time utilities, bestie β¨
okay so this is the CLOCK(9) page from the Kernel Developer's Manual, and it's literally a little bundle of time utilities from <sys/clock.h>. No cap, it's giving "small header, big kernel energy." π
πΈ NAME πΈ
days_in_month, is_leap_year, days_per_year β handy time utilities. That's the trio, and yes, they are literally described as handy time utilities. Periodt. π
β¨ SYNOPSIS β¨
#include <sys/clock.h>
#define SECS_PER_MINUTE 60
#define SECS_PER_HOUR 3600
#define SECS_PER_DAY 86400
#define DAYS_PER_COMMON_YEAR 365
#define DAYS_PER_LEAP_YEAR 366
#define SECS_PER_COMMON_YEAR (SECS_PER_DAY * DAYS_PER_COMMON_YEAR)
#define SECS_PER_LEAP_YEAR (SECS_PER_DAY * DAYS_PER_LEAP_YEAR)
static inline int
days_in_month(int m);
static inline int
is_leap_year(uint64_t year);
static inline int
days_per_year(uint64_t year);
π¦ DESCRIPTION π¦
The <sys/clock.h> file provides handy time constants and static inline functions. That's the whole vibe: useful constants + static inline functions, cute and compact. Slay. π«Ά
π FUNCTIONS π
days_in_month()β returns the number of days in the given month. It assumes 28 days for February. If the input value is out of the valid range (1-12), then the function returns-1. Bestie, respect the range. πis_leap_year()anddays_per_year()β take as the input parameter a value in the Gregorian year format. That's the leap-year duo, and they are not here to guess your calendar era. iykyk. π
π SEE ALSO π
Go peek at these besties:
bintime(9)boottime(9)time_second(9)time_uptime(9)todr_gettime(9)
π HISTORY π
The <sys/clock.h> header with handy utilities originated from <dev/clock_subr.h>, which originated from <arch/hp300/hp300/clock.c>. It's a whole lineage, honestly. π§
The <arch/hp300/hp300/clock.c> file first appeared in NetBSD 0.8 as a set of hp300 time-converting functions. Then <dev/clock_subr.h> first appeared in NetBSD 1.3 as a shared list of functions to convert between βyear/month/day/hour/minute/secondβ and seconds since 1970 (βPOSIX timeβ). The <sys/clock.h> file first appeared in NetBSD 8. Iconic evolution, no notes. π
π AUTHORS π
Kamil Rytarowski β give them their flowers. π
big love from Debian, dated December 26, 2014, on this CLOCK(9) manual page. That's the tea, bestie β bye! ππβ¨
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2014 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms