Blame lib/isc/unix/stdtime.c

Packit 5ce601
/*
Packit 5ce601
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
Packit 5ce601
 *
Packit 5ce601
 * This Source Code Form is subject to the terms of the Mozilla Public
Packit 5ce601
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Packit Service 704ed8
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
Packit 5ce601
 *
Packit 5ce601
 * See the COPYRIGHT file distributed with this work for additional
Packit 5ce601
 * information regarding copyright ownership.
Packit 5ce601
 */
Packit 5ce601
Packit 5ce601
Packit 5ce601
/*! \file */
Packit 5ce601
Packit 5ce601
#include <config.h>
Packit 5ce601
Packit 5ce601
#include <stdbool.h>
Packit 5ce601
#include <stddef.h>	/* NULL */
Packit 5ce601
#include <stdlib.h>	/* NULL */
Packit 5ce601
#include <syslog.h>
Packit 5ce601
Packit 5ce601
#include <sys/time.h>
Packit 5ce601
Packit 5ce601
#include <isc/stdtime.h>
Packit 5ce601
#include <isc/util.h>
Packit 5ce601
Packit 5ce601
void
Packit 5ce601
isc_stdtime_get(isc_stdtime_t *t) {
Packit 5ce601
	struct timeval tv;
Packit 5ce601
Packit 5ce601
	/*
Packit 5ce601
	 * Set 't' to the number of seconds since 00:00:00 UTC, January 1,
Packit 5ce601
	 * 1970.
Packit 5ce601
	 */
Packit 5ce601
Packit 5ce601
	REQUIRE(t != NULL);
Packit 5ce601
Packit 5ce601
	RUNTIME_CHECK(gettimeofday(&tv, NULL) != -1);
Packit 5ce601
Packit 5ce601
	*t = (unsigned int)tv.tv_sec;
Packit 5ce601
}