xref: /netbsd-src/share/man/man9/clock.9 (revision 7f88087bf0b65a7533e936c8e4924658171e7779)
1*7f88087bSwiz.\"     $NetBSD: clock.9,v 1.2 2014/12/26 14:15:18 wiz Exp $
26c377c63Swiz.\"
36c377c63Swiz.\" Copyright (c) 2014 The NetBSD Foundation, Inc.
46c377c63Swiz.\" All rights reserved.
56c377c63Swiz.\"
66c377c63Swiz.\" This code is contributed to The NetBSD Foundation by Kamil Rytarowski
76c377c63Swiz.\"
86c377c63Swiz.\" Redistribution and use in source and binary forms, with or without
96c377c63Swiz.\" modification, are permitted provided that the following conditions
106c377c63Swiz.\" are met:
116c377c63Swiz.\" 1. Redistributions of source code must retain the above copyright
126c377c63Swiz.\"    notice, this list of conditions and the following disclaimer.
136c377c63Swiz.\" 2. Redistributions in binary form must reproduce the above copyright
146c377c63Swiz.\"    notice, this list of conditions and the following disclaimer in the
156c377c63Swiz.\"    documentation and/or other materials provided with the distribution.
166c377c63Swiz.\"
176c377c63Swiz.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
186c377c63Swiz.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
196c377c63Swiz.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
206c377c63Swiz.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
216c377c63Swiz.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
226c377c63Swiz.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
236c377c63Swiz.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
246c377c63Swiz.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
256c377c63Swiz.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
266c377c63Swiz.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
276c377c63Swiz.\" POSSIBILITY OF SUCH DAMAGE.
286c377c63Swiz.\"
29*7f88087bSwiz.Dd December 26, 2014
306c377c63Swiz.Dt CLOCK 9
316c377c63Swiz.Os
326c377c63Swiz.Sh NAME
336c377c63Swiz.Nm days_in_month ,
346c377c63Swiz.Nm is_leap_year ,
356c377c63Swiz.Nm days_per_year
366c377c63Swiz.Nd handy time utilities
376c377c63Swiz.Sh SYNOPSIS
386c377c63Swiz.In sys/clock.h
396c377c63Swiz.Vt #define SECS_PER_MINUTE         60
406c377c63Swiz.Vt #define SECS_PER_HOUR           3600
416c377c63Swiz.Vt #define SECS_PER_DAY            86400
426c377c63Swiz.Vt #define DAYS_PER_COMMON_YEAR    365
436c377c63Swiz.Vt #define DAYS_PER_LEAP_YEAR      366
446c377c63Swiz.Vt #define SECS_PER_COMMON_YEAR    (SECS_PER_DAY * DAYS_PER_COMMON_YEAR)
456c377c63Swiz.Vt #define SECS_PER_LEAP_YEAR      (SECS_PER_DAY * DAYS_PER_LEAP_YEAR)
466c377c63Swiz.Ft static inline int
476c377c63Swiz.Fn days_in_month "int m"
486c377c63Swiz.Ft static inline int
496c377c63Swiz.Fn is_leap_year "uint64_t year"
506c377c63Swiz.Ft static inline int
516c377c63Swiz.Fn days_per_year "uint64_t year"
526c377c63Swiz.Sh DESCRIPTION
536c377c63SwizThe
546c377c63Swiz.In sys/clock.h
556c377c63Swizfile provides handy time constants and
566c377c63Swiz.Ft static inline
576c377c63Swizfunctions.
586c377c63Swiz.Sh FUNCTIONS
596c377c63SwizThe
606c377c63Swiz.Fn days_in_month
61*7f88087bSwizfunction returns the number of days in the given month.
62*7f88087bSwiz.Fn days_in_month
63*7f88087bSwizassumes 28 days for February.
646c377c63SwizIf the input value is out of the valid range (1-12) then the function returns
656c377c63Swiz\-1.
666c377c63Swiz.Pp
676c377c63SwizThe
686c377c63Swiz.Fn is_leap_year
696c377c63Swizand
706c377c63Swiz.Fn days_per_year
716c377c63Swizfunctions take as the input parameter a value in the Gregorian year format.
726c377c63Swiz.Sh SEE ALSO
736c377c63Swiz.Xr bintime 9 ,
746c377c63Swiz.Xr boottime 9 ,
756c377c63Swiz.Xr time_second 9 ,
766c377c63Swiz.Xr time_uptime 9 ,
776c377c63Swiz.Xr todr_gettime 9
786c377c63Swiz.Sh HISTORY
796c377c63SwizThe
806c377c63Swiz.In sys/clock.h
816c377c63Swizheader with handy utilities originated from
826c377c63Swiz.In dev/clock_subr.h ,
836c377c63Swizwhich originated from
846c377c63Swiz.In arch/hp300/hp300/clock.c .
856c377c63Swiz.Pp
866c377c63SwizThe
876c377c63Swiz.In arch/hp300/hp300/clock.c
886c377c63Swizfile first appeared in
896c377c63Swiz.Nx 0.8
906c377c63Swizas a set of hp300 time-converting functions.
916c377c63Swiz.In dev/clock_subr.h
926c377c63Swizfirst appeared in
936c377c63Swiz.Nx 1.3
946c377c63Swizas a shared list of functions to convert between
956c377c63Swiz.Dq year/month/day/hour/minute/second
966c377c63Swizand seconds since 1970
976c377c63Swiz.Pq Dq POSIX time .
986c377c63SwizThe
996c377c63Swiz.In sys/clock.h
1006c377c63Swizfile first appeared in
1016c377c63Swiz.Nx 8 .
1026c377c63Swiz.Sh AUTHORS
1036c377c63Swiz.An Kamil Rytarowski
104