2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-02 15:45:25 +00:00

implemented isc_time_formattimestamp() for Win32.

I have no way of testing this.
This commit is contained in:
Andreas Gustafsson
2001-08-31 22:31:18 +00:00
parent 6184f9fc1e
commit ff8cd3afa7
2 changed files with 38 additions and 2 deletions

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: time.h,v 1.19 2001/01/09 21:59:09 bwelling Exp $ */ /* $Id: time.h,v 1.20 2001/08/31 22:31:18 gson Exp $ */
#ifndef ISC_TIME_H #ifndef ISC_TIME_H
#define ISC_TIME_H 1 #define ISC_TIME_H 1
@@ -281,4 +281,18 @@ isc_time_nanoseconds(isc_time_t *t);
ISC_LANG_ENDDECLS ISC_LANG_ENDDECLS
void
isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len);
/*
* Format the time 't' into the buffer 'buf' of length 'len',
* using a format like "Aug 30 04:06:47.997" and the local time zone.
* If the text does not fit in the buffer, the result is indeterminate,
* but is always guaranteed to be null terminated.
*
* Requires:
* 'len' > 0
* 'buf' points to an array of at least len chars
*
*/
#endif /* ISC_TIME_H */ #endif /* ISC_TIME_H */

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: time.c,v 1.25 2001/08/30 04:31:31 mayer Exp $ */ /* $Id: time.c,v 1.26 2001/08/31 22:31:17 gson Exp $ */
/* /*
* Windows has a different epoch than Unix. Therefore this code sets the epoch * Windows has a different epoch than Unix. Therefore this code sets the epoch
@@ -374,3 +374,25 @@ isc_time_nanoseconds(isc_time_t *t) {
return ((isc_uint32_t)(st.wMilliseconds * 1000000)); return ((isc_uint32_t)(st.wMilliseconds * 1000000));
} }
void
isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
FILETIME localft;
SYSTEMTIME st;
static const char *months[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
REQUIRE(len > 0);
if (FileTimeToLocalFileTime(&t->absolute, &localft) &&
FileTimeToSystemTime(&localft, &st))
{
snprintf(buf, len, "%s %2u %02u:%02u:%02u.%03u",
months[st.wMonth], st.wDay, st.wHour, st.wMinute,
st.wSecond, st.wMilliseconds);
} else {
snprintf(buf, len, "<bad time>");
}
}