stdtime.c revision 15a44745412679c30a6d022733925af70a38b715
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews/*
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * Copyright (C) 1999, 2000 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * copyright notice and this permission notice appear in all copies.
207cee019eb5cbbe7c905f7c52f7b5d11f8c0305Automatic Updater *
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt */
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt/* $Id: stdtime.c,v 1.8 2000/07/27 09:52:55 tale Exp $ */
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt#include <config.h>
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt#include <sys/time.h>
61bcc232038f0a2cb77ed6269675fdc288f5ec98Evan Hunt
#include <isc/stdtime.h>
#include <isc/util.h>
void
isc_stdtime_get(isc_stdtime_t *t) {
struct timeval tv;
/*
* Set 't' to the number of seconds since 00:00:00 UTC, January 1,
* 1970.
*/
REQUIRE(t != NULL);
RUNTIME_CHECK(gettimeofday(&tv, NULL) != -1);
INSIST(tv.tv_usec >= 0 && tv.tv_usec < 1000000);
*t = (unsigned int)tv.tv_sec;
}