immutable class ELAPSED < $ORDERED{ELAPSED}, $HASH, $BINARY, $TEXT, $ANCHORED_FMT
****

________This_class_embodies_the_abstraction_of_a_period_of_time_rather_than
___an_instant_or_time-stamp.___Values_of_this_kind_are_never_negative.
_________Version_1.4_May_2001.___Copyright_K_Hopper,_U_of_Waikato
__________________________Development_History
__________________________-------------------
________Date___________Who_By_________Detail
________----___________------_________------
________3_Jun_96________kh_______Original_from_std_Sather_distrib.
________8_Apr_97________kh_______Modified_for_INT_to_CARD
_______25_Feb_98________kh_______made_a_sub-class_of_$BINARY
________5_Oct_98________kh_______factored_out_ELAPSED_STR.
_______29_Oct_98________kh_______Refined,_added_pre/post_conditions
_______31_May_01________kh_______Added_$ORDERED_sub-typing


Ancestors
$ANCHORED_FMT $FMT $STR $TEXT
$BINARY $HASH $IS_EQ $ORDERED{_}
$IS_LT{_} $VALUE{_} $NIL $IS_NIL



Public


Readable Attributes
attr days : CARD ;
attr millisecs : CARD ;

Constants
const Invalid : SAME := days(CARD::nil).millisecs(CARD::nil) ;

Features
binstr : BINSTR
build(cursor : BIN_CURSOR) : SAME
build(loc_cursor : STR_CURSOR) : SAME .. Included as build
create(str : BINSTR) : SAME .. Included as create
create(days : CARD, millis : CARD ) : SAME
create(str : STR) : SAME .. Included as create
create(dtime : TIME_STAMP) : SAME
****
________This_routine_creates_a_new_elapsed_time_--_elapsed_between_the_'base
___date'_and_dtime.
div( factor : CARD ) : SAME
fmt(format : ANCHORED_DESCR) : STR .. Included as fmt
fmt(format : ANCHORED_DESCR, lib : LIBCHARS ) : STR .. Included as fmt
full_str(lib : LIBCHARS) : STR .. Included as full_str
full_str : STR .. Included as full_str
hash : CARD
hours : CARD
is_elapsed( str : STR) : CONVERSION_RESULTS .. Included as is_elapsed
is_eq(other : SAME) : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_and_other_represent
___the_same_elapsed_time.
is_eq(other : $OB) : BOOL .. Included as is_eq
**** This is the generic equality predicate. c.f. the class $IS_EQ
is_lt(other : SAME ) : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_and_other_represent
___the_same_elapsed_time.
is_nil : BOOL
****
________This_predicate_returns_true_if_and_only_if_self_is_a_nil_time.
milliseconds : CARD
minus( other : SAME ) : SAME
minutes : CARD
minutes_in_hour : CARD
nil : SAME
****
__This_routine_yields_a_nil_elapsed_time.
one_day : SAME
****
________This_routine_yields_a_one_day_elapsed_time.
one_hour : SAME
****
________This_routine_yields_a_one_hour_elapsed_time.
one_minute : SAME
****
________This_routine_yields_a_one_minute_elapsed_time.
one_second : SAME
****
________This_routine_yields_a_one_second_elapsed_time.
plus( other : SAME) : SAME
read(index : BIN_CURSOR) : SAME .. Included as read
seconds : CARD
seconds_in_minute : CARD
str(lib : LIBCHARS) : STR .. Included as str
str : STR .. Included as str
times( factor : CARD ) : SAME
total_days : CARD
****
________This_routine_returns_the_whole_number_of_days_in_self
total_hours : CARD
total_milliseconds : CARD
total_minutes : CARD
total_seconds : CARD
write(fyle : BIN_FILE) .. Included as write


Private

const Days, Hours, Minutes, Seconds ; .. Included as Days
const Days, Hours, Minutes, Seconds ; .. Included as Hours
const Hours_per_Day : CARD := 24 ;
shared Messages : ARRAY{STR} ; .. Included as Messages
shared Messages : ARRAY{STR} ; .. Included as Messages
const Millisecs_per_Day : CARD := Millisecs_per_Second *
const Millisecs_per_Hour : CARD := 1000 * 60 * 60 ;
const Millisecs_per_Minute : CARD := 1000 * 60 ;
const Millisecs_per_Second : CARD := 1000 ;
const Days, Hours, Minutes, Seconds ; .. Included as Minutes
const Minutes_per_Day : CARD := 60 * Hours_per_Day ;
const Minutes_per_Hour : CARD := 60 ;
const Days, Hours, Minutes, Seconds ; .. Included as Seconds
const Seconds_per_Day : CARD := 60 * Minutes_per_Day ;
const Seconds_per_Minute : CARD := 60 ;
check_names(loc_lib : LIBCHARS) .. Included as check_names
****
________This_routine_reads_the_culturally-defined_names_for_days/hours/
___minutes/seconds_if_Messages_has_not_already_been_read.
attr days : CARD ;
do_times( factor : CARD ) : SAME
****
________This_routine_returns_an_elapsed_time_which_has_been_multiplied_by
___the_factor_indicated_provided_that_this_is_possible_without_over-run_when
___the_maximum_representable_elapsed_time_is_returned_-_which_is_nevertheless
___an_invalid_elapsed_time!!

___NOTE_This_has_no_pre-conditions_in_order_to_break_a_mutual_recursion_which
________would_otherwise_happen_indefinitely!
attr millisecs : CARD ;
scan(cursor : STR_CURSOR) : CARD .. Included as scan
subtract(from, sub : SAME ) : SAME

The Sather Home Page