Skip to content

Commit

Permalink
Merge branch 'topic/timw/fix-timestamp-parsing'
Browse files Browse the repository at this point in the history
* topic/timw/fix-timestamp-parsing:
  Don't add timezone offset to ISO time, since it results in errors
  Parse 'timestamp' fields from json received from Zeek correctly
  • Loading branch information
timwoj committed Dec 11, 2023
2 parents 0556d75 + f616839 commit 02097a6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
2.3.0-dev.59 | 2023-12-11 09:56:46 -0700

* Merge branch 'topic/timw/fix-timestamp-parsing'

* topic/timw/fix-timestamp-parsing:
Don't add timezone offset to ISO time, since it results in errors
Parse 'timestamp' fields from json received from Zeek correctly

* Don't add timezone offset to ISO time, since it results in errors

* Parse 'timestamp' fields from json received from Zeek correctly

* Update pathfind submodule for #include fix

2.3.0-dev.55 | 2023-12-01 09:42:11 -0700

* Add section about building for Windows to README
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-dev.55
2.3.0-dev.59
8 changes: 8 additions & 0 deletions src/io/zeek.cc
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,14 @@ static std::pair<Value, value::Type> from_json(const nlohmann::json& json) {
if ( type == "timespan" )
return {to_interval_from_secs(std::stoi(value.get<std::string>())), value::Type::Interval};

if ( type == "timestamp" ) {
std::tm tm = {};
std::istringstream ss(value.get<std::string>());
ss >> std::get_time(&tm, "%FT%T");
auto tp = std::chrono::system_clock::from_time_t(std::mktime(&tm));
return {tp, value::Type::Time};
}

/* Not supported, don't need these.
*
* if ( auto x = broker::get_if<broker::address>(&v) )
Expand Down
2 changes: 1 addition & 1 deletion src/util/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ inline std::string to_string_iso(Time t) {
auto tm = std::localtime(&teatime);

std::stringstream b;
b << std::put_time(tm, "%FT%T%z");
b << std::put_time(tm, "%FT%T");
return std::string(b.str());
}

Expand Down

0 comments on commit 02097a6

Please sign in to comment.