I have to give respect to @jan for showing me this. This became the most importent Pipeline we use in multiply environments.
rule "Between 6 PM and 6 AM"
when
( to_long(to_date($message.timestamp, "American/Chicago").hourOfDay) >= 0 AND to_long(to_date($message.timestamp, "American/Chicago").hourOfDay) <= 6 ) OR
( to_long(to_date($message.timestamp, "American/Chicago").hourOfDay) >= 18 AND to_long(to_date($message.timestamp, "American/Chicago").hourOfDay) <= 0 )
then
set_field("trigger_workhours_off", true);
end
rule "Off Work Weekend"
when
// from Monday (1) to Sunday (7)
to_long(to_date($message.timestamp, "American/Chicago").dayOfWeek) == 7 OR
to_long(to_date($message.timestamp, "American/Chicago").dayOfWeek) == 6
then
set_field("trigger_workhours_off", true);
end
Rule "Route to stream"
when
has_field("trigger_workhours_off")
then
route_to_stream(id:"5d8acba383d72e04cba96317");
end