Fixed formattimestamp to use locale specific dates and times, the same way as Unix format

This commit is contained in:
Danny Mayer 2001-10-08 01:20:08 +00:00
parent f08782f092
commit f3fcde886c

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: time.c,v 1.30 2001/09/30 02:41:11 mayer Exp $ */
/* $Id: time.c,v 1.31 2001/10/08 01:20:08 mayer Exp $ */
#include <config.h>
@ -69,7 +69,7 @@ isc_interval_set(isc_interval_t *i, unsigned int seconds,
}
isc_boolean_t
isc_interval_iszero(const isc_interval_t *i) {
isc_interval_iszero(isc_interval_t *i) {
REQUIRE(i != NULL);
if (i->interval == 0)
return (ISC_TRUE);
@ -86,7 +86,7 @@ isc_time_settoepoch(isc_time_t *t) {
}
isc_boolean_t
isc_time_isepoch(const isc_time_t *t) {
isc_time_isepoch(isc_time_t *t) {
REQUIRE(t != NULL);
if (t->absolute.dwLowDateTime == 0 &&
@ -106,7 +106,7 @@ isc_time_now(isc_time_t *t) {
}
isc_result_t
isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
isc_time_nowplusinterval(isc_time_t *t, isc_interval_t *i) {
ULARGE_INTEGER i1;
REQUIRE(t != NULL);
@ -129,15 +129,14 @@ isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
}
int
isc_time_compare(const isc_time_t *t1, const isc_time_t *t2) {
isc_time_compare(isc_time_t *t1, isc_time_t *t2) {
REQUIRE(t1 != NULL && t2 != NULL);
return ((int)CompareFileTime(&t1->absolute, &t2->absolute));
}
isc_result_t
isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result)
{
isc_time_add(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
ULARGE_INTEGER i1;
REQUIRE(t != NULL && i != NULL && result != NULL);
@ -157,8 +156,7 @@ isc_time_add(const isc_time_t *t, const isc_interval_t *i, isc_time_t *result)
}
isc_result_t
isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
isc_time_t *result) {
isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
ULARGE_INTEGER i1;
REQUIRE(t != NULL && i != NULL && result != NULL);
@ -178,7 +176,7 @@ isc_time_subtract(const isc_time_t *t, const isc_interval_t *i,
}
isc_uint64_t
isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
isc_time_microdiff(isc_time_t *t1, isc_time_t *t2) {
ULARGE_INTEGER i1, i2;
LONGLONG i3;
@ -201,7 +199,7 @@ isc_time_microdiff(const isc_time_t *t1, const isc_time_t *t2) {
}
isc_uint32_t
isc_time_nanoseconds(const isc_time_t *t) {
isc_time_nanoseconds(isc_time_t *t) {
SYSTEMTIME st;
/*
@ -217,21 +215,24 @@ void
isc_time_formattimestamp(const isc_time_t *t, char *buf, unsigned int len) {
FILETIME localft;
SYSTEMTIME st;
char DateBuf[50];
char TimeBuf[50];
static const char badtime[] = "Bad 00 99:99:99.999";
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 - 1], st.wDay, st.wHour, st.wMinute,
st.wSecond, st.wMilliseconds);
} else {
snprintf(buf, len, badtime);
FileTimeToSystemTime(&localft, &st)) {
GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, "MMM d", DateBuf,
50);
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOTIMEMARKER|
TIME_FORCE24HOURFORMAT, &st, NULL, TimeBuf, 50);
snprintf(buf, len, "%s %s.%03u", DateBuf, TimeBuf,
st.wMilliseconds);
}
else
snprintf(buf, len, badtime);
}