indexing
description: "Absolute dates"
status: "See notice at end of class"
date: "$Date$"
revision: "$Revision$"
access: date
class interface
DATE
create
make (y, m, d: INTEGER)
yearmonthdayymd
require
correct_date: is_correct_date (y, m, d)
ensure
year_set: year = y
month_set: month = m
day_set: day = d
make_month_day_year (m, d, y: INTEGER)
monthdayyearmdy
require
correct_date: is_correct_date (y, m, d)
ensure
year_set: year = y
month_set: month = m
day_set: day = d
make_day_month_year (d, m, y: INTEGER)
daymonthyeardmy
require
correct_date: is_correct_date (y, m, d)
ensure
year_set: year = y
month_set: month = m
day_set: day = d
make_now
make_by_days (n: INTEGER)
norigin
ensure
days_set: days = n
make_from_string_default (s: STRING)
date_default_format_string
require
s_exists: s /= void
date_valid: date_valid (s, date_default_format_string)
make_from_string_default_with_base (s: STRING; base: INTEGER)
date_default_format_stringbase
require
s_exists: s /= void
base_valid: base > 0 and (base \\ 100 = 0)
date_valid: date_valid_with_base (s, date_default_format_string, base)
make_from_string (s: STRING; code: STRING)
code
require
s_exists: s /= void
c_exists: code /= void
date_valid: date_valid (s, code)
make_from_string_with_base (s: STRING; code: STRING; base: INTEGER)
codebase
require
s_exists: s /= void
c_exists: code /= void
base_valid: base > 0 and (base \\ 100 = 0)
date_valid: date_valid_with_base (s, code, base)
make_by_compact_date (c_d: INTEGER)
compact_date
require
c_d_not_void: c_d /= void
c_d_valid: compact_date_valid (c_d)
ensure
compact_date_set: compact_date = c_d
feature
compact_date: INTEGER
DATE_VALUE
date_default_format_string: STRING
DATE_CONSTANTS
day: INTEGER
DATE_VALUE
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
month: INTEGER
DATE_VALUE
Months_in_year: INTEGER is 12
DATE_CONSTANTS
months_text: ARRAY [STRING]
DATE_CONSTANTS
origin: DATE
ensure ABSOLUTE
result_exists: Result /= void
year: INTEGER
DATE_VALUE
feature
days: INTEGER
origin
ensure
same_duration: Result = duration.day
duration: DATE_DURATION
origin
ensure then
definite_result: Result.definite
duration_set: ((Current - origin).duration).is_equal (Result)
feature
is_equal (other: like Current): BOOLEAN
other
COMPARABLE
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 COMPARABLE
trichotomy: Result = (not (Current < other) and not (other < Current))
max (other: like Current): like Current
other
COMPARABLE
require COMPARABLE
other_exists: other /= void
ensure COMPARABLE
current_if_not_smaller: Current >= other implies Result = Current
other_if_smaller: Current < other implies Result = other
min (other: like Current): like Current
other
COMPARABLE
require COMPARABLE
other_exists: other /= void
ensure COMPARABLE
current_if_not_greater: Current <= other implies Result = Current
other_if_greater: Current > other implies Result = other
three_way_comparison (other: like Current): INTEGER
other
COMPARABLE
require COMPARABLE
other_exists: other /= void
ensure COMPARABLE
equal_zero: (Result = 0) = is_equal (other)
smaller_negative: (Result = - 1) = (Current < other)
greater_positive: (Result = 1) = (Current > other)
infix "<" (other: like Current): BOOLEAN
other
require PART_COMPARABLE
other_exists: other /= void
ensure then COMPARABLE
asymmetric: Result implies not (other < Current)
infix "<=" (other: like Current): BOOLEAN
other
COMPARABLE
require PART_COMPARABLE
other_exists: other /= void
ensure then COMPARABLE
definition: Result = ((Current < other) or is_equal (other))
infix ">" (other: like Current): BOOLEAN
other
COMPARABLE
require PART_COMPARABLE
other_exists: other /= void
ensure then COMPARABLE
definition: Result = (other < Current)
infix ">=" (other: like Current): BOOLEAN
other
COMPARABLE
require PART_COMPARABLE
other_exists: other /= void
ensure then COMPARABLE
definition: Result = (other <= Current)
feature
day_of_january_1st: INTEGER
ensure
day_of_the_week_definition: Result > 0 and then Result < 8
day_of_the_week: INTEGER
ensure
day_of_the_week_range: Result > 0 and then Result < 8
days_at_month: INTEGER
ensure
positive_result: Result >= 0
days_from (y: INTEGER): INTEGER
y
days_in_year: INTEGER
ensure
valid_result: (leap_year implies Result = days_in_leap_year) and then (not leap_year implies Result = days_in_non_leap_year)
is_leap_year (y: INTEGER): BOOLEAN
y
DATE_CONSTANTS
leap_year: BOOLEAN
week_of_year: INTEGER
ensure
positive_result: Result >= 0
result_small_enough: Result < max_weeks_in_year
year_day: INTEGER
ensure
result_large_enough: Result >= 1
result_small_enough: Result <= days_in_year
feature
set_day (d: INTEGER)
dayd
DATE_VALUE
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
DATE_VALUE
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
DATE_VALUE
require DATE_MEASUREMENT
can_not_cut_29th_feb: day <= days_in_i_th_month (month, y)
ensure DATE_MEASUREMENT
year_set: year = y
feature
to_date_time: DATE_TIME
feature
add (d: DATE_DURATION)
d
d
day_add (d: INTEGER)
d
ensure
days_set: days = old days + d
day_back
ensure
days_set: days = old days - 1
day_forth
ensure
days_set: days = old days + 1
month_add (m: INTEGER)
m
month_back
month_forth
relative_duration (other: like Current): DATE_DURATION
other
require ABSOLUTE
other_exists: other /= void
ensure ABSOLUTE
result_exists: Result /= void
ensure then
exact_duration: (other + Result).is_equal (Current)
canonical_duration: Result.canonical (other)
origin_date_set: equal (Result.origin_date, other)
year_add (y: INTEGER)
y
ensure
year_set: year = old year + y
year_back
ensure
year_decreased: year = old year - 1
year_forth
ensure
year_increased: year = old year + 1
year_month_add (y, m: INTEGER)
ym
infix "+" (d: DATE_DURATION): DATE
d
ensure
result_exists: Result /= void
definite_set: d.definite implies (Result - Current).duration.is_equal (d)
infix "-" (other: like Current): INTERVAL [like Current]
other
ABSOLUTE
require ABSOLUTE
other_exists: other /= void
other_smaller_than_current: other <= Current
ensure ABSOLUTE
result_exists: Result /= void
result_set: Result.start_bound.is_equal (other) and then Result.end_bound.is_equal (Current)
feature
formatted_out (s: STRING): STRING
Current
s
require
s_exists: s /= void
out: STRING
Current
date_default_format_string
feature
compact_date_valid (c_d: INTEGER): BOOLEAN
c_d
DATE_VALIDITY_CHECKER
date_valid (s: STRING; code_string: STRING): BOOLEAN
DATE
scode_string
DATE_VALIDITY_CHECKER
require DATE_VALIDITY_CHECKER
s_exists: s /= void
code_exists: code_string /= void
date_valid_default (s: STRING): BOOLEAN
DATE
s
date_default_format_string
DATE_VALIDITY_CHECKER
require DATE_VALIDITY_CHECKER
s_exists: s /= void
date_valid_default_with_base (s: STRING; base: INTEGER): BOOLEAN
DATE
s
date_default_format_string
base
DATE_VALIDITY_CHECKER
require DATE_VALIDITY_CHECKER
s_exists: s /= void
base_valid: base > 0 and (base \\ 100 = 0)
date_valid_with_base (s: STRING; code_string: STRING; base: INTEGER): BOOLEAN
DATE
scode_string
base
DATE_VALIDITY_CHECKER
require DATE_VALIDITY_CHECKER
s_exists: s /= void
code_exists: code_string /= void
base_valid: base > 0 and (base \\ 100 = 0)
is_correct_date (y, m, d: INTEGER): BOOLEAN
ymd
DATE_VALIDITY_CHECKER
feature
days_in_month: INTEGER
DATE_MEASUREMENT
ensure DATE_MEASUREMENT
positive_result: Result > 0
invariant
day_large_enough: day >= 1
day_small_enough: day <= days_in_month
month_large_enough: month >= 1
month_small_enough: month <= months_in_year
year_small_enough: year <= 65535
year_positive: year > 0
ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)
COMPARABLE
irreflexive_comparison: not (Current < Current)
end -- DATE