1999-09-23 14:34:27 -04:00
|
|
|
/*
|
2018-02-23 03:53:12 -05:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-07-31 21:33:37 -04:00
|
|
|
*
|
2016-06-27 00:56:38 -04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
2020-09-14 19:50:58 -04:00
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 03:53:12 -05:00
|
|
|
*
|
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
|
* information regarding copyright ownership.
|
1999-09-23 14:34:27 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
|
#include <isc/assertions.h>
|
|
|
|
|
#include <isc/stdtime.h>
|
2001-07-06 01:08:39 -04:00
|
|
|
#include <isc/util.h>
|
1999-09-23 14:34:27 -04:00
|
|
|
|
1999-12-16 18:29:07 -05:00
|
|
|
void
|
2020-02-14 00:35:17 -05:00
|
|
|
isc_stdtime_get(isc_stdtime_t *t) {
|
1999-09-23 14:34:27 -04:00
|
|
|
/*
|
|
|
|
|
* Set 't' to the number of seconds past 00:00:00 UTC, January 1, 1970.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
REQUIRE(t != NULL);
|
|
|
|
|
|
2013-12-03 20:47:23 -05:00
|
|
|
(void)_time32(t);
|
1999-09-23 14:34:27 -04:00
|
|
|
}
|
2020-06-17 08:00:09 -04:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
isc_stdtime_tostring(isc_stdtime_t t, char *out, size_t outlen) {
|
|
|
|
|
time_t when;
|
|
|
|
|
|
|
|
|
|
REQUIRE(out != NULL);
|
|
|
|
|
/* Minimum buffer as per ctime_r() specification. */
|
|
|
|
|
REQUIRE(outlen >= 26);
|
|
|
|
|
|
|
|
|
|
/* time_t and isc_stdtime_t might be different sizes */
|
|
|
|
|
when = t;
|
|
|
|
|
INSIST((ctime_s(out, outlen, &when) == 0));
|
|
|
|
|
*(out + strlen(out) - 1) = '\0';
|
|
|
|
|
}
|