<br> That is a tricky question. :) Drools 4 has no special semantics for date and time, and so, the only date and time you can get is the Java date/time, and for that you need to use an eval() to call a function (or API) to return current date and time:<br>
<br>eval( currentDateFunction() == $someOtherDate )<br><br> Drools 5, on the other hand, has the concept of session clock, as part of the incoming support for events. The session clock can be used to write rules against it, as well as add temporal constrainst to events. For instance:<br>
<br>$aPhoneCall : PhoneCall( )<br>$anotherCall : PhoneCall( this after[10,60] $aPhoneCall )<br><br> The above constraint will be true, when $anotherCall happens 10 to 60 time units after $aPhoneCall. But when did the calls occurred? that is determined by the clock abstraction chosen for the given session, that may be either a system synchronized clock, as well as a pseudo-clock implementation (that enables session re-executions and scenario simulations), or an externally stamped timestamp (that keeps the events timestamps frozen), etc.<br>
<br> It will also allow for the explicit definition of time windows (see our presentation at JBoss World, etc).<br><br> All the above, just to tell you all users that time is not a simple concept to support. Drools 4 didn't tried to do it, but Drools 5 will bring some interesting modeling power to the table. <br>
<br> Edson<br><br><br><br><div class="gmail_quote">2008/5/7 Christine <<a href="mailto:christine@christine.nl">christine@christine.nl</a>>:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Talking about date and time, how do I get current date in a when condition?<br>
<br>
dagdag<br>
Christine<br>
<div class="Ih2E3d"><br>
<br>
> Exactly. Also, you need to make sure you "tell the engine" everytime<br>
> your<br>
> Time object change, as well as ensure that fireAllRules will be called at<br>
> the exact time: 22:00, because if it is called 1 minute later or before,<br>
> the<br>
> constraint will evaluate to false.<br>
><br>
> Edson<br>
><br>
><br>
</div>> 2008/5/7 Christine <<a href="mailto:christine@christine.nl">christine@christine.nl</a>>:<br>
<div class="Ih2E3d">><br>
>> > Hi everyone,<br>
>><br>
>> > For example:<br>
>> > when Time(hour==22,minute==0) Lamp(status==1)<br>
>> > then<br>
>> > Console.Writeline("It's late,turn off the light and go to bed")<br>
>> > where time is a class that return the current hour;<br>
>><br>
>> Claudio, this would probably work if you fire the rules every hour or<br>
>> every minute or every time your Time object changes. Just having the<br>
>> rules<br>
>> sitting in your rulebase doesn't mean they get executed.<br>
>><br>
>> Christine<br>
>><br>
>><br>
>> _______________________________________________<br>
>> rules-users mailing list<br>
>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
</div><div class="Ih2E3d">>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> Edson Tirelli<br>
> JBoss Drools Core Development<br>
> Office: +55 11 3529-6000<br>
> Mobile: +55 11 9287-5646<br>
> JBoss, a division of Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
</div><div><div></div><div class="Wj3C7c">> _______________________________________________<br>
> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>