<!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 = Pattern.compile(
"([+-])?((\\d+)[Dd])?\\s*((\\d+)[Hh])?\\s*((\\d+)[Mm])?\\s*((\\d+)[Ss])?\\s*((\\d+)([Mm][Ss])?)?"
);<br>
<br>
public static long parseTimeString( String time ) {<br>
String trimmed = time.trim();<br>
long result = 0;<br>
if( trimmed.length() > 0 ) {<br>
Matcher mat = SIMPLE.matcher( trimmed );<br>
if ( mat.matches() ) {<br>
int days = (mat.group( SIM_DAY ) != null) ?
Integer.parseInt( mat.group( SIM_DAY ) ) : 0;<br>
int hours = (mat.group( SIM_HOU ) != null) ?
Integer.parseInt( mat.group( SIM_HOU ) ) : 0;<br>
int min = (mat.group( SIM_MIN ) != null) ?
Integer.parseInt( mat.group( SIM_MIN ) ) : 0;<br>
int sec = (mat.group( SIM_SEC ) != null) ?
Integer.parseInt( mat.group( SIM_SEC ) ) : 0;<br>
int ms = (mat.group( SIM_MS ) != null) ?
Integer.parseInt( mat.group( SIM_MS ) ) : 0;<br>
long r = days * DAY_MS + hours * HOU_MS + min *
MIN_MS + sec * SEC_MS + ms;<br>
if( mat.group(SIM_SGN) != null && mat.group(
SIM_SGN ).equals( "-" ) ) {<br>
r = -r;<br>
}<br>
result = r;<br>
} else if( "*".equals( trimmed ) || "+*".equals( trimmed
) ) {<br>
// positive infinity<br>
result = Long.MAX_VALUE;<br>
} else if( "-*".equals( trimmed ) ) {<br>
// negative infinity<br>
result = Long.MIN_VALUE;<br>
} else {<br>
throw new RuntimeDroolsException( "Error parsing
time string: [ " + time + " ]" );<br>
}<br>
}<br>
return result;<br>
}<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"><<a
moz-do-not-send="true" href="mailto:rouvas@mm.di.uoa.gr">rouvas@mm.di.uoa.gr</a>></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>
</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>
> See the "Fusion" manual, section on Temporal
Reasoning/Temporal Operators.<br>
> Even when the facts aren't events, these operators can
still be applied to<br>
> fields of type Date, e.g.<br>
><br>
> $p1: Person( $dob1: dob )<br>
> $p2: Person( $dob2: dob after[3d] $dob1 )<br>
><br>
> -W<br>
><br>
><br>
> On 28 June 2011 18:02, <<a moz-do-not-send="true"
href="mailto:rouvas@mm.di.uoa.gr">rouvas@mm.di.uoa.gr</a>>
wrote:<br>
><br>
>> Hi list,<br>
>><br>
>> I feel this should be an elementary question but
unfortunately I haven't<br>
>> been able to find a solution.<br>
>><br>
>> I would like to perform date arithmetic in the when
part of a rule.<br>
>><br>
>> For example, I would like to express something like:<br>
>><br>
>> rule "Date compare rule"<br>
>> dialect "mvel"<br>
>> when<br>
>> a : A()<br>
>> b : B( a.creationDate <= b.creationDate after 3
months)<br>
>> then<br>
>> ...<br>
>> end<br>
>><br>
>> Apart from using eval()'s is there any other way to
express these types<br>
>> of<br>
>> comparisons?<br>
>><br>
>> Thank you for your time,<br>
>> -Stathis<br>
>><br>
>><br>
>> _______________________________________________<br>
>> rules-users mailing list<br>
>> <a moz-do-not-send="true"
href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>> <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>
>><br>
><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>