Skip to content

Commit

Permalink
Fixed date time initialization
Browse files Browse the repository at this point in the history
Signed-off-by: Piet Gömpel <[email protected]>
  • Loading branch information
Pietfried committed Oct 16, 2024
1 parent 1345abe commit 9ef17fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/OCPP201/error_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ ocpp::v201::EventData get_event_data(const Everest::error::Error& error, const b
ocpp::v201::EventData event_data;
event_data.eventId = event_id; // This can theoretically conflict with eventIds generated in libocpp (e.g.
// for monitoring events), but the spec does not strictly forbid that
event_data.timestamp = ocpp_conversions::to_ocpp_datetime_or_now(error.timestamp);
try {
event_data.timestamp = ocpp::DateTime(error.timestamp);
} catch (const ocpp::TimePointParseException& e) {
event_data.timestamp = ocpp::DateTime();
}
event_data.trigger = ocpp::v201::EventTriggerEnum::Alerting;
event_data.cause = std::nullopt; // TODO: use caused_by when available within error object
event_data.actualValue = cleared ? "false" : "true";
Expand Down

0 comments on commit 9ef17fa

Please sign in to comment.