Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set (PACKAGE_VERSION "${VERSION}")
set (PACKAGE_STRING "${PACKAGE} ${VERSION}")

check_function_exists(strlcpy HAVE_STRLCPY)
check_function_exists(timegm HAVE_TIMEGM)

message ("-- Configuring cmake.h")
configure_file (
Expand Down
4 changes: 3 additions & 1 deletion cmake.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
/* Found strlcpy() */
#cmakedefine HAVE_STRLCPY

/* Found timegm(struct tm*) */
#cmakedefine HAVE_TIMEGM

/* Functions */
#cmakedefine HAVE_GET_CURRENT_DIR_NAME
#cmakedefine HAVE_TIMEGM
#cmakedefine HAVE_UUID_UNPARSE_LOWER

17 changes: 17 additions & 0 deletions src/Datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3119,6 +3119,23 @@ bool Datetime::validate ()
return true;
}

#ifndef HAVE_TIMEGM
time_t Datetime::timegm(struct tm* tm) {
time_t ret;
char* tz;
tz = getenv("TZ");
setenv("TZ", "UTC", 1);
tzset();
ret = mktime(tm);
if (tz)
setenv("TZ", tz, 1);
else
unsetenv("TZ");
tzset();
return ret;
}
#endif

////////////////////////////////////////////////////////////////////////////////
// int tm_sec; seconds (0 - 60)
// int tm_min; minutes (0 - 59)
Expand Down
4 changes: 4 additions & 0 deletions src/Datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ class Datetime
bool validate ();
void resolve ();

#ifndef HAVE_TIMEGM
time_t timegm(struct tm*);
#endif

public:
int _year {0};
int _month {0};
Expand Down