Thanks, Dave, for the patch! We'll fix the code snippet with the commit. Do you have a query that helps us to reproduce the bug? Christian
On Tue, Oct 5, 2010 at 10:18 PM, Dave Glick dglick@dracorp.com wrote:
I think there might be a bug in Date.diff – it looks like if the number of days are the same, it attempts to directly cast the incoming Item to a Date in order to compare seconds. However, if the incoming Item is actually a string or something else a cast failure will occur. My fix is below:
Old code:
@Override
public int diff(final InputInfo ii, final Item it) throws QueryException {
final long d1 = days();
final Date d = (Date) (it.date() ? it : type.e(it, null, ii));
final long d2 = d.days();
if(d1 != d2) return (int) (d1 - d2);
return seconds().subtract(((Date) it).seconds()).signum();
}
New code:
@Override
public int diff(final InputInfo ii, final Item it) throws QueryException {
final long d1 = days();
final Date d = (Date) (it.date() ? it : type.e(it, null, ii));
final long d2 = d.days();
if(d1 != d2) return (int) (d1 - d2);
return seconds().subtract(d.seconds()).signum();
}
Dave
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk