note description: "Absolute dates" legal: "See notice at end of class." status: "See notice at end of class." date: "$Date: 2017-03-29 12:26:46 +0000 (Wed, 29 Mar 2017) $" revision: "$Revision: 100065 $" access: date eis: "name=DATE / TIME to STRING Conversion", "src=$(ISE_DOC_UUID)/88972ba4-694b-8558-b0c8-87b1fc40afc4", "tag=EiffelTime" eis: "name=Obtaining a DATE from a DATE_TIME and vice versa", "src=$(ISE_DOC_UUID)/195849fc-1a9c-d734-2d2b-acae78133886#Obtaining_a_DATE_from_a_DATE_TIME_and_vice_versa", "tag=EiffelTime" class interface DATE create make, make_month_day_year, make_day_month_year, make_now, make_now_utc, make_by_days, make_from_string_default, make_from_string_default_with_base, make_from_string, make_from_string_with_base, make_by_compact_date, make_by_ordered_compact_date feature -- Initialization make (y, m, d: INTEGER_32) -- Set year, month and day to y, m, d respectively. 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_32) -- Set month, day and year to m, d and y respectively. 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_32) -- Set day, month and year to d, m and y respectively. require correct_date: is_correct_date (y, m, d) ensure year_set: year = y month_set: month = m day_set: day = d make_now -- Set the current object to today's date. make_now_utc -- Set the current object to today's date in utc format. make_by_days (n: INTEGER_32) -- Set the current date with the number of days n since Origin. ensure days_set: days = n make_from_string_default (s: STRING_8) -- Initialize from a "standard" string of form -- date_default_format_string. -- (For 2-digit year specifications, the current century is used as -- base century.) require s_exists: s /= Void date_valid: date_valid (s, date_default_format_string) make_from_string_default_with_base (s: STRING_8; base: INTEGER_32) -- Initialize from a "standard" string of form -- date_default_format_string with base century base. 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_8; code: STRING_8) -- Initialize from a "standard" string of form -- code. -- (For 2-digit year specifications, the current century is used as -- base century.) require s_exists: s /= Void c_exists: code /= Void date_valid: date_valid (s, code) make_from_string_with_base (s: STRING_8; code: STRING_8; base: INTEGER_32) -- Initialize from a "standard" string of form -- code with base century base. 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_ordered_compact_date (c_d: INTEGER_32) -- Initialize from a ordered_compact_date. require c_d_valid: ordered_compact_date_valid (c_d) ensure ordered_compact_date_set: ordered_compact_date = c_d feature -- Access Origin: DATE -- Origin date feature -- Comparison is_less alias "<" (other: like Current): BOOLEAN -- Is the current date before other? feature -- Measurement duration: DATE_DURATION -- Definite duration elapsed since Origin ensure then definite_result: Result.definite duration_set: ((Current - Origin).duration).is_equal (Result) days: INTEGER_32 -- Number of days elapsed since Origin ensure same_duration: Result = duration.day feature -- Status report leap_year: BOOLEAN -- Is the current year a leap year? days_at_month: INTEGER_32 -- Number of days from the beginning of the year -- until the beginning of the current month ensure positive_result: Result >= 0 year_day: INTEGER_32 -- Number of days from the beginning of the year ensure result_large_enough: Result >= 1 result_small_enough: Result <= days_in_year week_of_year: INTEGER_32 -- Number of weeks from the beginning of the year -- The first week of the year begins on the first sunday of the year -- The week number before the first sunday of the year is 0 ensure positive_result: Result >= 0 result_small_enough: Result < Max_weeks_in_year days_in_year: INTEGER_32 -- Number of days in the current year ensure valid_result: (leap_year implies Result = Days_in_leap_year) and then (not leap_year implies Result = Days_in_non_leap_year) day_of_the_week: INTEGER_32 -- Number of day from the beginning of the week -- sunday is 1, etc.., saturday is 7 ensure day_of_the_week_range: Result > 0 and then Result < 8 day_of_january_1st: INTEGER_32 -- Day of the week of january 1st of the current year ensure day_of_the_week_definition: Result > 0 and then Result < 8 days_from (y: INTEGER_32): INTEGER_32 -- Days between the current year and year y feature -- Conversion to_date_time: DATE_TIME -- Date-time version, with a zero time component feature -- Basic operations plus alias "+" (d: DATE_DURATION): DATE -- Sum to current date the duration d -- if duration not define, add years and then months and then days. require d_not_void: d /= Void ensure result_exists: Result /= Void definite_set: d.definite implies (Result - Current).duration.is_equal (d) add (d: DATE_DURATION) -- Adds d to the current date. -- if d is not definite, add years and months and then days. require d_not_void: d /= Void relative_duration (other: like Current): DATE_DURATION -- Duration from other to the current date ensure then exact_duration: (other + Result).is_equal (Current) canonical_duration: Result.canonical (other) origin_date_set: equal (Result.origin_date, other) day_forth -- Move to next day. -- days is from the origin, day is current. ensure days_set: days = old days + 1 day_back -- Move to previous day. ensure days_set: days = old days - 1 day_add (d: INTEGER_32) -- Add d days to the current date. ensure days_set: days = old days + d month_forth -- Move to next month. -- Can move days backward if next month has less days than the -- current month. month_back -- Move to previous month. -- Can move days backward if previous month has less days than the -- current month. month_add (m: INTEGER_32) -- Add m months to the current date. -- Can move days backward. year_forth -- Move to next year. -- May cut the 29th february. ensure year_increased: year = old year + 1 year_back -- Move to previous year. -- May cut the 29th february. ensure year_decreased: year = old year - 1 year_add (y: INTEGER_32) -- Add y years to the current date. -- May cut the 29th february. ensure year_set: year = old year + y year_month_add (y, m: INTEGER_32) -- Add y years and m months to the current date. -- Check the number of days after. feature -- Output debug_output: STRING_8 -- Printable representation of Current with "standard" -- Form: date_default_format_string -- Was declared in DATE as synonym of out. out: STRING_8 -- Printable representation of Current with "standard" -- Form: date_default_format_string -- Was declared in DATE as synonym of debug_output. formatted_out (s: STRING_8): STRING_8 -- Printable representation of Current with "standard" -- Form: s require s_exists: s /= Void 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_non_negative: year >= 0 note copyright: "Copyright (c) 1984-2017, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class DATE
Generated by ISE EiffelStudio