diff --git a/dtls_debug.c b/dtls_debug.c index 5f88e6c1..4f93e606 100644 --- a/dtls_debug.c +++ b/dtls_debug.c @@ -77,6 +77,8 @@ static const char *loglevels[] = { #ifdef HAVE_TIME_H +#ifndef IS_WINDOWS + static inline size_t print_timestamp(char *s, size_t len, time_t t) { struct tm *tmp; @@ -84,6 +86,21 @@ print_timestamp(char *s, size_t len, time_t t) { return strftime(s, len, "%b %d %H:%M:%S", tmp); } +#else + +static inline size_t +print_timestamp(char *s, size_t len, time_t t) { + struct tm tmp; + errno_t err = localtime_s(&tmp, &t); + if (err) { + printf("Invalid argument to localtime_s."); + exit(1); + } + return strftime(s, len, "%b %d %H:%M:%S", &tmp); +} + +#endif + #else /* alternative implementation: just print the timestamp */ static inline size_t