1.\" $NetBSD: inittodr.9,v 1.4 1999/04/06 20:24:56 pk Exp $ 2.\" 3.\" Copyright (c) 1994 Christopher G. Demetriou 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by Christopher G. Demetriou 17.\" for the NetBSD Project. 18.\" 4. The name of the author may not be used to endorse or promote products 19.\" derived from this software without specific prior written permission 20.\" 21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31.\" 32.Dd November 13, 1995 33.Dt INITTODR 9 34.Os 35.Sh NAME 36.Nm inittodr 37.Nd initialize system time 38.Sh SYNOPSIS 39.Ft void 40.Fn inittodr "time_t base" 41.Sh DESCRIPTION 42The 43.Fn inittodr 44function determines the time and sets the system clock. 45It tries to pick the correct time using a set of heuristics that examine 46the system's battery backed clock and the time reported by the file 47system, as given in 48.Fa base . 49Those heuristics include: 50.Bl -bullet 51.It 52If the battery-backed clock has a valid time, it is used. 53.It 54If the battery-backed clock does not have a valid time, and 55the time provided in 56.Fa base 57is within reason, 58.Fa base 59is used as the current time. 60.It 61If the battery-backed clock appears invalid, and 62.Fa base 63appears non-sensical or was not provided (was given as zero), 64a arbitrary base (typically some time in the late 1970s) 65will be used. 66.El 67.Pp 68Once a system time has been determined, it is stored in the 69.Va time 70variable. 71.Sh DIAGNOSTICS 72The 73.Fn inittodr 74function prints diagnostic messages if it has trouble figuring 75out the system time. Conditions that can cause diagnostic 76messages to be printed include: 77.Bl -bullet 78.It 79The battery-backed clock's time appears nonsensical. 80.It 81The 82.Fa base 83time appears nonsensical. 84.It 85The 86.Fa base 87time and the battery-backed clock's time differ by a large amount. 88.El 89.Sh SEE ALSO 90.Xr resettodr 9 , 91.Xr time 9 92.Sh BUGS 93On many systems, 94.Fn inittodr 95has to convert from 96a time expressed in terms of year, month, day, hours, minutes, 97and seconds to 98.Va time , 99expressed in seconds. Many of the implementations could share code, 100but do not. 101.Pp 102Each system's heuristics for picking the correct time are slightly 103different. 104