Skip to content
Snippets Groups Projects

Make mtime omni-parsable

Closed Remo Dietlicher requested to merge omni-fix into master
1 file
+ 18
17
Compare changes
  • Side-by-side
  • Inline
+ 18
17
@@ -15,6 +15,8 @@
#include "mtime_timedelta.h"
#include "mtime_julianDay.h"
#define BASICEVENT_THRESHOLD 20
/**
* @brief Auxiliary function: Test for zero-length time interval.
@@ -238,8 +240,18 @@ newBasicEventWithDataType(const char* _en,
struct _juliandelta *jdelta_tmp;
jdelta_tmp = timeDeltaToJulianDelta(e->eventInterval, e->eventReferenceDateTime, &e->jd_eventInterval);
/* check if the event interval is smaller than one month
(otherwise this cannot be handled by the basic event
object). */
if (e->jd_eventInterval.day > BASICEVENT_THRESHOLD) {
char tdstring[MAX_TIMEDELTA_STR_LEN];
fprintf(stderr, "Interval '%s' cannot be handled by basic event object!\n",
timedeltaToString(e->eventInterval, tdstring));
goto cleanup_and_exit;
}
/* Init the Flags. */
e->triggerCurrentEvent = false;
e->triggerCurrentEvent = true;
/* --- Determine event start, event end boundaries. --- */
{
@@ -366,31 +378,17 @@ isCurrentBasicEventActive(struct _event_basic* event,
struct _timedelta* minus_slack)
{
// TODO
// if not event active: return
// TODO:
//
// Duplicate the mtime_event stuff; name: "mtime_frequentEvent"
//
// CHECKS: check if
// - event, current_dt are not NULL
// - the event interval is smaller than one month (this can be
// handled by the event init routine)
// - the slack is smaller than a day (enough to be representable
// in milliseconds and simplifies comparisons)
// - current_dt is within [event start, end]
// (we do not consider the slack beyond this interval)
// - document these restrictions as a subroutine comment
// - implement check for plus/minus slack
//
// IGNORED (document this!)
// - eventsLastEvaluationDateTime
// - triggeredPreviousEventDateTime
//
// AFTER the calculation
//
// - take care of persistent event state
// -- eventsLastEvaluationDateTime
// -- when to set "triggerCurrentEvent"?
@@ -405,6 +403,8 @@ isCurrentBasicEventActive(struct _event_basic* event,
//printf("current_dt: %s\n", datetimeToString(current_dt, dstring));
//printf("eventReferenceDateTime: %s\n", datetimeToString(event->eventReferenceDateTime, dstring));
if ((event == NULL) || (current_dt == NULL)) return false;
if (!event->triggerCurrentEvent) return false;
/* convert "current_dt" into Julian date. */
struct _julianday jd1 = { .day=0, .ms=0 };
@@ -418,7 +418,8 @@ isCurrentBasicEventActive(struct _event_basic* event,
struct _divisionquotienttimespan *quo_ret, quo_tmp;
quo_ret = divideJulianDelta(&td_tmp, &event->jd_eventInterval, &quo_tmp);
/* compare to start, end of event here: */
/* compare to start, end of event (we do not consider the slack
beyond this interval): */
if (compareDivisionQuotientTimespan(&quo_tmp, &event->quot_eventFirstDateTime) == less_than)
return false;
if (compareDivisionQuotientTimespan(&quo_tmp, &event->quot_eventLastDateTime) == greater_than)
Loading