if given timestamp is in the future, reset it, it is likely invalid

This commit is contained in:
Isaac Connor 2018-01-31 14:33:20 -05:00
parent ba2c111762
commit c9bc5a8cd8
1 changed files with 7 additions and 1 deletions

View File

@ -60,10 +60,16 @@ Event::Event(
std::string notes; std::string notes;
createNotes(notes); createNotes(notes);
struct timeval now;
gettimeofday(&now, 0);
bool untimedEvent = false; bool untimedEvent = false;
if ( !start_time.tv_sec ) { if ( !start_time.tv_sec ) {
untimedEvent = true; untimedEvent = true;
gettimeofday(&start_time, 0); start_time = now;
} else if ( start_time.tv_sec > now.tv_sec ) {
Error("StartTime in the future");
start_time = now;
} }
Storage * storage = monitor->getStorage(); Storage * storage = monitor->getStorage();