indexing
description: "Durations of date"
status: "See notice at end of class"
date: "$Date$"
revision: "$Revision$"
access: date
class interface
DATE_DURATION
create
make (y, m, d: INTEGER)
yearmonthdayymd
ensure
year_set: year = y
month_set: month = m
day_set: day = d
make_by_days (d: INTEGER)
dayd
ensure
day_set: day = d
definite_duration: definite
feature
make (y, m, d: INTEGER)
yearmonthdayymd
ensure
year_set: year = y
month_set: month = m
day_set: day = d
make_by_days (d: INTEGER)
dayd
ensure
day_set: day = d
definite_duration: definite
feature
date_default_format_string: STRING
DATE_CONSTANTS
days_in_i_th_month (i, y: INTEGER): INTEGER
iy
DATE_CONSTANTS
require DATE_CONSTANTS
i_large_enough: i >= 1
i_small_enough: i <= months_in_year
Days_in_leap_year: INTEGER is 366
DATE_CONSTANTS
Days_in_non_leap_year: INTEGER is 365
DATE_CONSTANTS
Days_in_week: INTEGER is 7
DATE_CONSTANTS
days_text: ARRAY [STRING]
DATE_CONSTANTS
long_days_text: ARRAY [STRING]
DATE_CONSTANTS
long_months_text: ARRAY [STRING]
DATE_CONSTANTS
Max_weeks_in_year: INTEGER is 53
DATE_CONSTANTS
Months_in_year: INTEGER is 12
DATE_CONSTANTS
months_text: ARRAY [STRING]
DATE_CONSTANTS
zero: DATE_DURATION
ensure GROUP_ELEMENT
result_exists: Result /= void
ensure then
definite: Result.definite
feature
is_equal (other: like Current): BOOLEAN
other
require ANY
other_not_void: other /= void
ensure ANY
symmetric: Result implies other.is_equal (Current)
consistent: standard_is_equal (other) implies Result
ensure then
result_definition: Result = (year = other.year and then month = other.month and then day = other.day)
infix "<" (other: like Current): BOOLEAN
other
require PART_COMPARABLE
other_exists: other /= void
ensure then
definite_duration: (definite and then other.definite) implies Result = (day < other.day)
non_definite_duration: (not definite or else not other.definite) implies Result = False
infix "<=" (other: like Current): BOOLEAN
other
PART_COMPARABLE
require PART_COMPARABLE
other_exists: other /= void
infix ">" (other: like Current): BOOLEAN
other
PART_COMPARABLE
require PART_COMPARABLE
other_exists: other /= void
infix ">=" (other: like Current): BOOLEAN
other
PART_COMPARABLE
require PART_COMPARABLE
other_exists: other /= void
feature
canonical (date: DATE): BOOLEAN
date
date
year
month
day
date
year
month
day
require
date_exist: date /= void
definite: BOOLEAN
day
yearmonthday
ensure
result_definition: Result = ((year = 0) and then (month = 0))
has_origin_date: BOOLEAN
is_leap_year (y: INTEGER): BOOLEAN
y
DATE_CONSTANTS
is_negative: BOOLEAN
DURATION
is_positive: BOOLEAN
is_zero: BOOLEAN
DURATION
feature
set_origin_date (d: DATE)
origin_dated
ensure
origin_date_set: origin_date = d
feature
prefix "+": like Current
DURATION
ensure GROUP_ELEMENT
result_exists: Result /= void
result_definition: Result.is_equal (Current)
infix "-" (other: like Current): like Current
other
DURATION
require GROUP_ELEMENT
other_exists: other /= void
ensure GROUP_ELEMENT
result_exists: Result /= void
feature
to_canonical (start_date: DATE): like Current
date
ensure
canonical_result: Result.canonical (start_date)
duration_not_changed: equal (start_date + Current, start_date + Result)
to_date_time: DATE_TIME_DURATION
ensure
result_exists: Result /= void
year_set: Result.year = year
month_set: Result.month = month
day_set: Result.day = day
to_definite (date: DATE)
require
date_exists: date /= void
ensure
definite_result: definite
feature
infix "+" (other: like Current): like Current
other
require GROUP_ELEMENT
other_exists: other /= void
ensure GROUP_ELEMENT
result_exists: Result /= void
commutative: Result.is_equal (other + Current)
ensure then
origin_equal: equal (origin_date, Result.origin_date)
prefix "-": like Current
ensure GROUP_ELEMENT
result_exists: Result /= void
result_definition: (Result + Current).is_equal (zero)
ensure then
origin_equal: equal (origin_date, Result.origin_date)
feature
day: INTEGER
days_count: INTEGER
require
origin_date_set: has_origin_date
month: INTEGER
origin_date: DATE
year: INTEGER
feature
day_add (d: INTEGER)
dCurrent
ensure
day_set: day = old day + d
month_add (m: INTEGER)
mCurrent
ensure
month_set: month = old month + m
set_day (d: INTEGER)
dayd
require DATE_MEASUREMENT
d_large_enough: d >= 1
d_small_enough: d <= days_in_month
ensure DATE_MEASUREMENT
day_set: day = d
set_month (m: INTEGER)
monthm
require DATE_MEASUREMENT
m_large_enough: m >= 1
m_small_enough: m <= months_in_year
d_small_enough: day <= days_in_i_th_month (m, year)
ensure DATE_MEASUREMENT
month_set: month = m
set_year (y: INTEGER)
yeary
require DATE_MEASUREMENT
can_not_cut_29th_feb: day <= days_in_i_th_month (month, y)
ensure DATE_MEASUREMENT
year_set: year = y
year_add (y: INTEGER)
yCurrent
ensure
year_set: year = old year + y
feature
days_in_month: INTEGER
DATE_MEASUREMENT
ensure DATE_MEASUREMENT
positive_result: Result > 0
invariant
equal_signs: (has_origin_date and then canonical (origin_date)) implies (day >= 0 and month >= 0 and year >= 0) or (day <= 0 and month <= 0 and year <= 0)
ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)
DURATION
sign_correctness: is_positive xor is_negative xor is_zero
GROUP_ELEMENT
neutral_addition: Current.is_equal (Current + zero)
self_subtraction: zero.is_equal (Current - Current)
end -- DATE_DURATION