note description: "Universal constants about 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 class DATE_CONSTANTS inherit TIME_UTILITY export {NONE} mod, div end create default_create feature -- Access Days_in_week: INTEGER_32 = 7 -- Number of days in a week Max_weeks_in_year: INTEGER_32 = 53 -- Maximun number of weeks in a year Months_in_year: INTEGER_32 = 12 -- Number of months in year Days_in_leap_year: INTEGER_32 = 366 -- Number of days in a leap year Days_in_non_leap_year: INTEGER_32 = 365 -- Number of days in a non-leap year days_in_i_th_month (i, y: INTEGER_32): INTEGER_32 -- Number of days in the i th month at year y require i_large_enough: i >= 1 i_small_enough: i <= Months_in_year do Result := Days_in_months @ i if i = 2 and then is_leap_year (y) then Result := Result + 1 end end date_default_format_string: STRING_8 -- Default output format for dates do Result := Date_time_tools.Date_default_format_string end days_text: ARRAY [STRING_8] -- Short text representation of days do Result := Date_time_tools.Days_text end months_text: ARRAY [STRING_8] -- Short text representation of months do Result := Date_time_tools.Months_text end long_days_text: ARRAY [STRING_8] -- Long text representation of days do Result := Date_time_tools.Long_days_text end long_months_text: ARRAY [STRING_8] -- Long text representation of months do Result := Date_time_tools.Long_months_text end feature -- Status report i_th_leap_year (i: INTEGER_32): BOOLEAN obsolete "Use `is_leap_year' instead. [2017-05-31]" do Result := is_leap_year (i) end is_leap_year (y: INTEGER_32): BOOLEAN -- Is year y a leap year? do Result := (mod (y, 4) = 0) and ((mod (y, 100) /= 0) or (mod (y, 400) = 0)) end feature {NONE} -- Implementation Days_in_months: ARRAY [INTEGER_32] -- Array containing number of days for each month of -- a non-leap year. once Result := <<31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31>> ensure result_exists: Result /= Void valid_count: Result.count = Months_in_year end 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_CONSTANTS
Generated by ISE EiffelStudio