Skip to content

Commit

Permalink
Improve error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
vvromanov committed Dec 2, 2024
1 parent 87830da commit 6058d58
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/common_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <arpa/inet.h>
#include <climits>
#include <cstdint>
#include "LogBase.h"

#ifdef __CYGWIN__
extern "C" {
Expand Down Expand Up @@ -191,7 +192,7 @@ bool ConvertStringIp(const char *data, in_addr_t &ip_network) {
}

bool ConvertStringTime(const char *data, time_t &time) {
struct tm tm;
struct tm tm = { 0 };
char *p;
if (strlen(data) > 4 && data[4] == '-') {
p = strptime(data, DATE_TIME_FORMAT1, &tm);
Expand All @@ -203,7 +204,17 @@ bool ConvertStringTime(const char *data, time_t &time) {
}
time = mktime(&tm); // t is now your desired time_t
if (time == -1) {
fprintf(stderr, "Date=%s tm_year=%d", data, tm.tm_year);
log_write(LOG_LEVEL_ERR, "\nDate=%s %d-%d-%d %d:%d:%d is_dst=%d zone=%s off=%ld\n ", data,
tm.tm_year,
tm.tm_mon+1,
tm.tm_mday,
tm.tm_hour,
tm.tm_min,
tm.tm_sec,
tm.tm_isdst,
tm.tm_zone? tm.tm_zone:"?",
tm.tm_gmtoff
);
}
return true;
}
Expand Down

0 comments on commit 6058d58

Please sign in to comment.