NAME
days_in_month,
is_leap_year,
days_per_year —
handy time
utilities
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.
FUNCTIONS
The
days_in_month() function returns the number of days in the
given month.
days_in_month() assumes 28 days for February.
If the input value is out of the valid range (1-12) then the function returns
-1.
The
is_leap_year() and
days_per_year()
functions take as the input parameter a value in the Gregorian year format.
SEE ALSO
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>.
The
<arch/hp300/hp300/clock.c> file
first appeared in
NetBSD 0.8 as a set of hp300
time-converting functions.
<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.
AUTHORS
Kamil Rytarowski