so we can round dates up / down as appropriate.
Note that this really only works for fixed periods of time_delta,
such as seconds / minutes / hours / days. It doesn't work for
months.
}
}
+ /*
+ * date % (time_delta) 1d --> time_delta
+ */
+ if (op == T_MOD) {
+ /*
+ * We MUST specify date ranges as a time delta, not as an integer. And it must be a
+ * positive time delta.
+ */
+ if ((b->type != FR_TYPE_TIME_DELTA) || !fr_time_delta_ispos(b->vb_time_delta)) {
+ return ERR_INVALID;
+ }
+
+ dst->vb_time_delta = fr_time_delta_wrap(fr_unix_time_unwrap(a->vb_date) % fr_time_delta_unwrap(b->vb_time_delta));
+ return 0;
+ }
+
/*
* Unix times are always converted 1-1 to our internal
* TIME_DELTA.
if (hint != FR_TYPE_NULL) break;
}
+ /*
+ * date % time_delta --> time_delta
+ */
+ if ((op == T_MOD) && (a->type == FR_TYPE_DATE)) {
+ hint = FR_TYPE_TIME_DELTA;
+ break;
+ }
+
switch (op) {
case T_OP_CMP_EQ:
case T_OP_NE: