From 7665c63da045636cb640401e4450573e6e76e169 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 9 Jul 2024 08:14:09 -0400 Subject: [PATCH] Add datetime as a zms option --- src/zms.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/zms.cpp b/src/zms.cpp index f5bca10d77..6f7ee5aaed 100644 --- a/src/zms.cpp +++ b/src/zms.cpp @@ -24,6 +24,8 @@ #include "zm_monitorstream.h" #include "zm_eventstream.h" #include "zm_fifo_stream.h" +#include +#include #include #include @@ -154,6 +156,12 @@ int main(int argc, const char *argv[], char **envp) { monitor_id = atoi(value); if ( source == ZMS_UNKNOWN ) source = ZMS_MONITOR; + } else if ( !strcmp(name, "datetime") ) { + std::tm tm = {}; + std::stringstream ss(value); + ss >> std::get_time(&tm, "%Y-%m-%d %H:%M:%S"); + auto tp = std::chrono::system_clock::from_time_t(std::mktime(&tm)); + event_time = std::chrono::duration_cast(tp.time_since_epoch()).count(); } else if ( !strcmp(name, "time") ) { event_time = atoi(value); } else if ( !strcmp(name, "event") ) {