6.3 Methods for comparison of times
We need to compare times to see whether they are the same, and to see whether one is greater (later) than another. These methods do the comparisons we need:
define method \< (time1 :: <time-of-day>, time2 :: <time-of-day>) time1.total-seconds < time2.total-seconds; end method \<; define method \< (time1 :: <time-offset>, time2 :: <time-offset>) time1.total-seconds < time2.total-seconds; end method \<; define method \= (time1 :: <time-of-day>, time2 :: <time-of-day>) time1.total-seconds = time2.total-seconds; end method \=; define method \= (time1 :: <time-offset>, time2 :: <time-offset>) time1.total-seconds = time2.total-seconds; end method \=;
We can call these methods:
? *plus-15-20-45* = *minus-2-hours*; #f
To compare times, we need only to define methods for < and =. All other numerical comparisons in Dylan are based on these two methods. So, we can call >, >=, <=, and ~= (the not-equal-to function). Here are examples:
? *plus-15-20-45* ~= *minus-2-hours*; #t ? *plus-15-20-45* > *minus-2-hours*; #t




