processing pipeline `to_date` ignores timezone
Expected Behavior
using the to_date function in a processing pipeline to transform a date into the local timezone to be able to compare it like in the following rule:
rule "off work hours"
when
( to_long(to_date($message.timestamp, "Asia/Manila").hourOfDay) >= 0 AND to_long(to_date($message.timestamp, "Asia/Manila").hourOfDay) <= 6 ) OR
( to_long(to_date($message.timestamp, "Asia/Manila").hourOfDay) >= 18 AND to_long(to_date($message.timestamp, "Asia/Manila").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, "Asia/Manila").dayOfWeek) == 7 OR
to_long(to_date($message.timestamp, "Asia/Manila").dayOfWeek) == 6
then
set_field("trigger_workhours_off", true);
end
Current Behavior
Graylog does not honour the timezone but the online docs announce this option:

Context
Make decisions based on time is hard and sometimes impossible if you need do the calculation in UTC - as this is what is currently only working in Graylog.
Your Environment
- Graylog Version: 3.1
The to_date function takes a second argument but does not use it.
https://github.com/Graylog2/graylog2-server/blob/master/graylog2-server/src/main/java/org/graylog/plugins/pipelineprocessor/functions/dates/DateConversion.java#L40
The fix seems that we simply add withZone(timezone) to the returning date object.