expanded class interface MICROSECOND_TIME
--
-- Date and time facilities (like TIME) plus an extra microsecond information.
--
feature(s) from HASHABLE
hash_code: INTEGER
-- The hash-code value of Current.
ensure
good_hash_value: Result >= 0
feature(s) from COMPARABLE
is_equal (other: like Current): BOOLEAN
-- Is other attached to an object considered equal to
-- current object ?
require
other /= Void
ensure
trichotomy: Result = (not (Current < other) and not (other < Current));
generating_type = other.generating_type implies Result = other.is_equal(Current)
infix "<" (other: like Current): BOOLEAN
-- Is Current strictly less than other?
require
other_exists: other /= Void
ensure
Result implies elapsed_seconds(other) > 0;
asymmetric: Result implies not (other < Current)
infix "<=" (other: like Current): BOOLEAN
-- Is Current less than or equal other?
require
other_exists: other /= Void
ensure
definition: Result = (Current < other or is_equal(other))
infix ">" (other: like Current): BOOLEAN
-- Is Current strictly greater than other?
require
other_exists: other /= Void
ensure
definition: Result = (other < Current)
infix ">=" (other: like Current): BOOLEAN
-- Is Current greater than or equal than other?
require
other_exists: other /= Void
ensure
definition: Result = (other <= Current)
in_range (lower, upper: like Current): BOOLEAN
-- Return True if Current is in range [lower..upper]
ensure
Result = (Current >= lower and Current <= upper)
compare (other: like Current): INTEGER
-- If current object equal to other, 0
-- if smaller, -1; if greater, 1.
require
other_exists: other /= Void
ensure
equal_zero: Result = 0 = is_equal(other);
smaller_negative: Result = -1 = (Current < other);
greater_positive: Result = 1 = (Current > other)
three_way_comparison (other: like Current): INTEGER
-- If current object equal to other, 0
-- if smaller, -1; if greater, 1.
require
other_exists: other /= Void
ensure
equal_zero: Result = 0 = is_equal(other);
smaller_negative: Result = -1 = (Current < other);
greater_positive: Result = 1 = (Current > other)
min (other: like Current): like Current
-- Minimum of Current and other.
require
other /= Void
ensure
Result <= Current and then Result <= other;
compare(Result) = 0 or else other.compare(Result) = 0
max (other: like Current): like Current
-- Maximum of Current and other.
require
other /= Void
ensure
Result >= Current and then Result >= other;
compare(Result) = 0 or else other.compare(Result) = 0
feature(s) from MICROSECOND_TIME
time: TIME
-- The normal TIME with second accuracy.
microsecond: INTEGER
-- Extra information in number of microseconds in range 0 .. 999999.
-- Note that the accuracy is system dependant.
update
-- Update Current with the current system clock.
set_time (t: TIME)
ensure
time = t
set_microsecond (microsec: INTEGER)
-- To set microsecond in range 0 .. 999 999.
require
microsec.in_range(0,999_999)
ensure
microsecond = microsec
infix "+" (s: DOUBLE): like Current
-- Add s seconds (2.476 is 2 seconds and 476 milliseconds)
require
s >= 0.0
add_second (s: INTEGER)
-- Add s seconds to Current.
require
s >= 0
ensure
Current >= old Current
add_millisecond (millisecond: INTEGER)
-- Add millisecond milliseconds.
require
millisecond.in_range(0,999)
ensure
Current >= old Current
add_microsecond (microsec: INTEGER)
-- Add microsec microseconds
require
microsec.in_range(0,999_999)
ensure
Current >= old Current
elapsed_seconds (other: like Current): DOUBLE
-- Elapsed time in seconds from Current to other with sub-second
-- precision.
feature(s) from MICROSECOND_TIME
basic_microsecond_time: INTEGER_64
basic_microsecond_microsecond: INTEGER
basic_microsecond_update
invariant
microsecond.in_range(0,999999);
end of expanded MICROSECOND_TIME