Comparing TimeSpans

May 5, 2011 at 4:24 PM

I'm passing TimeSpans into an expression, but I cannot compare them

The expression is something like "StartTime <= EndTime"

The error message is "Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible'

I guess I could add a custom function to do the comparison, but wondered if there was a simpler trick.

May 5, 2011 at 4:55 PM

I have been able to work round this with (StartTime.CompareTo(EndTime) <= 0) but if the objects are IComparable as TimeSpans are, it sure would be nice to support the infix forms, < <= > >= and ==

(I should mention I'm using the current (0.9.0) release)

Developer
May 6, 2011 at 5:14 AM

I've added support for compare operations on IComparable CLR objects, and corrected the error from your first post.

May 6, 2011 at 1:08 PM
cin wrote:

I've added support for compare operations on IComparable CLR objects, and corrected the error from your first post.

That was fast! Thanks.