INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Date class implementation"
project: "The Universal Time & Date UTDC"
revision: "$Revision: 1.1 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: timedate
class DATE
inherit

SIMPLE_TIMESTAMP
redefine
out
end
creation

clear,
set_date,
set_from_absolute_days,
set_local_time,
set_to_now
feature -- Queries: change-over date
-- This is the date when Julian calendar was switched to Gregorian one
-- The date is different for different countries
-- Here it is the date used by Pope Gregory XIII

change_over_year: INTEGER

change_over_month: INTEGER

change_over_day: INTEGER
feature -- Status

absolute_days: INTEGER
-- Julian days: the number of days since January 1, 4713 B.C.
ensure
Result >= 0

set_date (yr, mh, dy: INTEGER)
-- Set the date to the given value
require
date_valid: tt.valid_date (yr, mh, dy)
ensure
date_set: year = yr and month = mh and day = dy

set_from_absolute_days (i: INTEGER)
require
absolute_days_valid: i >= 0
ensure
absolute_days_set: absolute_days = i

set_to_now
-- Set the current date

set_local_time
-- Set the current local date

clear
feature -- Queries

infix "<" (ts: like Current): BOOLEAN

infix "+", plus (d: LONG_DURATION): like Current
require
date_valid: (absolute_days + d.as_days) > 0

infix "-", minus (d: LONG_DURATION): like Current
require
date_valid: (absolute_days - d.whole_days) > 0

difference (t: like Current): LONG_DURATION

day_of_week: INTEGER

is_leap_year: BOOLEAN
-- Is the year leap?
feature -- Status

year: INTEGER

month: INTEGER

day: INTEGER
feature -- Status: compatibility features

year_part: INTEGER
obsolete "This feature will be removed soon: use year instead"
-- Year

month_part: INTEGER
obsolete "This feature will be removed soon: use month instead"
-- Month

day_part: INTEGER
obsolete "This feature will be removed soon: use day instead"
-- Day
feature -- Output

out: STRING
-- New string containing printable represantation
-- Format is "YYYY-MM-DD" or "YYYY-MM-DD B.C."
invariant

valid_date: tt.valid_date (year, month, day)
end -- class DATE

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES