When I first started ECMA scripts I used the design with blockly option and wrote the code with it. I saved the blockly code and then click on the code tab of the rule and the ECMA script code is there.
I used that method to get the syntax and code structure. I am still not an expert but that got me started. I don’t use DSL rules anymore.
For simple rules I just use the UI for example below:
For everything else I just copy and past from example codes etc.
PS: To get the hour you have to do this:
var datetoday = new Date();
var hour_now = datetoday.getHours();
Good luck with ECMA. I have been using it for about 6 months.