CLOCK(9)

πŸ“¦ version 11.0, in nixpkgs unstable

✨ 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() and days_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:


πŸŽ€ 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