Skip to content

Commit

Permalink
Add datetime as a zms option
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Connor committed Jul 9, 2024
1 parent a993ddb commit 7665c63
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/zms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "zm_monitorstream.h"
#include "zm_eventstream.h"
#include "zm_fifo_stream.h"
#include <iomanip>
#include <sstream>
#include <string>
#include <unistd.h>

Expand Down Expand Up @@ -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<FPSeconds>(tp.time_since_epoch()).count();
} else if ( !strcmp(name, "time") ) {
event_time = atoi(value);
} else if ( !strcmp(name, "event") ) {
Expand Down

0 comments on commit 7665c63

Please sign in to comment.