<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    The times attempt to be ISO8601 compliant, for Hours and earlier.
    Although I noticed that tidbit of information is missing for the
    docs, we'll get it added. See TimeUtils<br>
    <br>
    private static final Pattern SIMPLE&nbsp; = Pattern.compile(
    "([+-])?((\\d+)[Dd])?\\s*((\\d+)[Hh])?\\s*((\\d+)[Mm])?\\s*((\\d+)[Ss])?\\s*((\\d+)([Mm][Ss])?)?"
    );<br>
    <br>
    &nbsp;&nbsp;&nbsp; public static long parseTimeString( String time ) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String trimmed = time.trim();<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long result = 0;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( trimmed.length() &gt; 0 ) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Matcher mat = SIMPLE.matcher( trimmed );<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( mat.matches() ) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int days = (mat.group( SIM_DAY ) != null) ?
    Integer.parseInt( mat.group( SIM_DAY ) ) : 0;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int hours = (mat.group( SIM_HOU ) != null) ?
    Integer.parseInt( mat.group( SIM_HOU ) ) : 0;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int min = (mat.group( SIM_MIN ) != null) ?
    Integer.parseInt( mat.group( SIM_MIN ) ) : 0;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int sec = (mat.group( SIM_SEC ) != null) ?
    Integer.parseInt( mat.group( SIM_SEC ) ) : 0;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int ms = (mat.group( SIM_MS ) != null) ?
    Integer.parseInt( mat.group( SIM_MS ) ) : 0;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; long r = days * DAY_MS + hours * HOU_MS + min *
    MIN_MS + sec * SEC_MS + ms;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if( mat.group(SIM_SGN) != null &amp;&amp; mat.group(
    SIM_SGN ).equals( "-" ) ) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r = -r;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = r;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else if( "*".equals( trimmed ) || "+*".equals( trimmed
    ) ) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // positive infinity<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = Long.MAX_VALUE;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else if( "-*".equals( trimmed ) ) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // negative infinity<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; result = Long.MIN_VALUE;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new RuntimeDroolsException( "Error parsing
    time string: [ " + time + " ]" );<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return result;<br>
    &nbsp;&nbsp;&nbsp; }<br>
    <br>
    <br>
    On 01/07/2011 06:21, Wolfgang Laun wrote:
    <blockquote
      cite="mid:BANLkTikmsUHP03cAaZE_qux2kii=Zs863A@mail.gmail.com"
      type="cite">2011/6/30 <span dir="ltr">&lt;<a
          moz-do-not-send="true" href="mailto:rouvas@mm.di.uoa.gr">rouvas@mm.di.uoa.gr</a>&gt;</span><br>
      <div class="gmail_quote">
        <blockquote class="gmail_quote" style="border-left: 1px solid
          rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
          1ex;">
          What are the available symbolics for temporal values?<br>
          That is, d is for days, m is for minutes, h is for hours, s is
          for seconds.<br>
          Are there any other symbolics specifically for months and
          years?<br>
        </blockquote>
        <div><br>
          You can use ms for millisecond. There are no universally
          acceptable duration values for monts and years .<br>
          -W<br>
          &nbsp;</div>
        <blockquote class="gmail_quote" style="border-left: 1px solid
          rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:
          1ex;">
          <br>
          I haven't found any mentioning of them in the Fusion manual.<br>
          I'm using 5.0.1<br>
          <br>
          Thank you,<br>
          -Stathis<br>
          <br>
          Wolfgang Laun wrote:<br>
          &gt; See the "Fusion" manual, section on Temporal
          Reasoning/Temporal Operators.<br>
          &gt; Even when the facts aren't events, these operators can
          still be applied to<br>
          &gt; fields of type Date, e.g.<br>
          &gt;<br>
          &gt; &nbsp; &nbsp; $p1: Person( $dob1: dob )<br>
          &gt; &nbsp; &nbsp; $p2: Person( $dob2: dob after[3d] $dob1 )<br>
          &gt;<br>
          &gt; -W<br>
          &gt;<br>
          &gt;<br>
          &gt; On 28 June 2011 18:02, &lt;<a moz-do-not-send="true"
            href="mailto:rouvas@mm.di.uoa.gr">rouvas@mm.di.uoa.gr</a>&gt;
          wrote:<br>
          &gt;<br>
          &gt;&gt; Hi list,<br>
          &gt;&gt;<br>
          &gt;&gt; I feel this should be an elementary question but
          unfortunately I haven't<br>
          &gt;&gt; been able to find a solution.<br>
          &gt;&gt;<br>
          &gt;&gt; I would like to perform date arithmetic in the when
          part of a rule.<br>
          &gt;&gt;<br>
          &gt;&gt; For example, I would like to express something like:<br>
          &gt;&gt;<br>
          &gt;&gt; rule "Date compare rule"<br>
          &gt;&gt; &nbsp;dialect "mvel"<br>
          &gt;&gt; when<br>
          &gt;&gt; &nbsp;a : A()<br>
          &gt;&gt; &nbsp;b : B( a.creationDate &lt;= b.creationDate after 3
          months)<br>
          &gt;&gt; then<br>
          &gt;&gt; &nbsp;...<br>
          &gt;&gt; end<br>
          &gt;&gt;<br>
          &gt;&gt; Apart from using eval()'s is there any other way to
          express these types<br>
          &gt;&gt; of<br>
          &gt;&gt; comparisons?<br>
          &gt;&gt;<br>
          &gt;&gt; Thank you for your time,<br>
          &gt;&gt; -Stathis<br>
          &gt;&gt;<br>
          &gt;&gt;<br>
          &gt;&gt; _______________________________________________<br>
          &gt;&gt; rules-users mailing list<br>
          &gt;&gt; <a moz-do-not-send="true"
            href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
          &gt;&gt; <a moz-do-not-send="true"
            href="https://lists.jboss.org/mailman/listinfo/rules-users"
            target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
          &gt;&gt;<br>
          &gt;<br>
          <br>
          <br>
        </blockquote>
      </div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>