I’ve added another tag to the AIML 2.0 spec. I may change some of the attributes for this tag, and I’d appreciate any feedback here before I cast it in stone.
The <interval> tag will be included in the next release of Program AB. It relies on the Joda-Time library http://joda.sourceforge.net/
The <interval> tag computes a time interval between two dates.
Like other AIML 2.0 tags, the attribute values of <interval> may be specified as XML attributes or with subtags of the same name. The attributes of <interval> are:
<style> - minutes, hours, days, weeks, months, or years
<jformat> - the format of the dates in the interval. (See <date/>).
<from> - starting date
<to> - ending date
Examples:
Compute the number of days until Christmas:
<category>
<pattern>HOW MANY DAYS UNTIL CHRISTMAS</pattern>
<template>
<interval>
<jformat>MMMMMMMMM dd</jformat>
<style>days</style>
<from><date jformat="MMMMMMMMM dd"/></from>
<to>December 25</to>
</interval>
days until Christmas.
</template>
</category>
The following category displays the bot’s age in years, or in months if the bot is less than one year old.
<category><pattern>AGE</pattern>
<template>
<think>
<set var="years">
<interval>
<jformat>MMMMMMMMM dd, YYYY</jformat>
<style>years</style>
<from>October 9, 2012</from>
<to><date jformat="MMMMMMMMM dd, YYYY"/></to>
</interval>
</set>
<set var="months">
<interval>
<jformat>MMMMMMMMM dd, YYYY</jformat>
<style>months</style>
<from>October 9, 2012</from>
<to><date jformat="MMMMMMMMM dd, YYYY"/></to>
</interval>
</set>
</think>
<condition var="years">
<li value="0">I am <get var="months"/> months old.</li>
<li>I am <get var="years"/> years old.</li>
</condition>
</template>
</category>