diff --git a/metadata.json b/metadata.json index 5a7e0e6..30c78b5 100644 --- a/metadata.json +++ b/metadata.json @@ -27,7 +27,7 @@ "capabilities": [], "nix": { "packages": { - "runtime": ["postgresql", "nlohmann_json"] + "runtime": ["libpq", "nlohmann_json"] }, "external_libraries": [ { diff --git a/src/delivery_module_plugin.cpp b/src/delivery_module_plugin.cpp index 74e129e..5a816d3 100644 --- a/src/delivery_module_plugin.cpp +++ b/src/delivery_module_plugin.cpp @@ -1,4 +1,5 @@ #include "delivery_module_plugin.h" +#include #include #include #include @@ -34,9 +35,13 @@ std::vector base64Decode(const std::string& encoded) { } int64_t currentTimestampNs() { - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - return static_cast(ts.tv_sec) * 1000000000LL + static_cast(ts.tv_nsec); + // std::chrono rather than clock_gettime(CLOCK_REALTIME): the POSIX call is + // not available on mingw (neither the function nor CLOCK_REALTIME is + // declared), which broke the Windows cross-build. system_clock is the + // portable spelling of the same wall-clock reading. + return std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); } } // namespace