Class DT_GREGORIAN_CALENDAR PreviousNext

note
description:

    "Gregorian calendar properties"

library:    "Gobo Eiffel Time Library"
author:     "Eric Bezault <ericb@gobosoft.com>"
copyright:  "Copyright (c) 2000-2001, Eric Bezault and others"
license:    "MIT License"
class interface
DT_GREGORIAN_CALENDAR
feature -- Year
leap_year (y: INTEGER): BOOLEAN
        -- Is y a leap year?
Months_in_year: INTEGER
        -- Number of months in a year
    ensure
        definition: Result = (December - Januray + 1)
Days_in_year: INTEGER
Days_in_leap_year: INTEGER
        -- Number of days in a (leap) year
Days_in_400_years: INTEGER
Days_in_100_years: INTEGER
Days_in_4_years: INTEGER
Days_in_3_years: INTEGER
Days_in_3_leap_years: INTEGER
Days_in_2_years: INTEGER
Days_in_2_leap_years: INTEGER
        -- Number of days in multiple years
feature -- Month
January: INTEGER
February: INTEGER
March: INTEGER
April: INTEGER
May: INTEGER
June: INTEGER
July: INTEGER
August: INTEGER
September: INTEGER
October: INTEGER
November: INTEGER
December: INTEGER
        -- Months
days_in_month (m, y: INTEGER): INTEGER
        -- Number of days in month m of year y
    require
        m_large_enough: m >= January
        m_small_enough: m <= December
    ensure
        at_least_one: Result >= 1
        max_days_in_month: Result <= Max_days_in_month
Max_days_in_month: INTEGER
        -- Maximum number of days in a month
days_at_month (m, y: INTEGER): INTEGER
        -- Number of days from beginning of year
        -- y until beginning of month m
    require
        m_large_enough: m >= January
        m_small_enough: m <= December
    ensure
        days_positive: Result >= 0
feature -- Week day
Sunday: INTEGER
Monday: INTEGER
Tuesday: INTEGER
Wednesday: INTEGER
Thursday: INTEGER
Friday: INTEGER
Saturday: INTEGER
        -- Week days
Days_in_week: INTEGER
        -- Number of days in a week
    ensure
        definition: Result = (Saturday - Sunday + 1)
next_day (d: INTEGER): INTEGER
        -- Week day after d
    require
        d_large_enough: d >= Sunday
        d_small_enough: d <= Saturday
    ensure
        sunday_definition: (d = Sunday) implies (Result = Monday)
        monday_definition: (d = Monday) implies (Result = Tuesday)
        tuesday_definition: (d = Tuesday) implies (Result = Wednesday)
        wednesday_definition: (d = Wednesday) implies (Result = Thursday)
        thursday_definition: (d = Thursday) implies (Result= Friday)
        friday_definition: (d = Friday) implies (Result = Saturday)
        saturday_definition: (d = Saturday) implies (Result = Sunday)
previous_day (d: INTEGER): INTEGER
        -- Week day before d
    require
        d_large_enough: d >= Sunday
        d_small_enough: d <= Saturday
    ensure
        sunday_definition: (d = Sunday) implies (Result = Saturday)
        monday_definition: (d = Monday) implies (Result = Sunday)
        tuesday_definition: (d = Tuesday) implies (Result = Monday)
        wednesday_definition: (d = Wednesday) implies (Result = Tuesday)
        thursday_definition: (d = Thursday) implies (Result= Wednesday)
        friday_definition: (d = Friday) implies (Result = Thursday)
        saturday_definition: (d = Saturday) implies (Result = Friday)
feature -- Time
Seconds_in_minute: INTEGER
        -- Number of seconds in a minute
Seconds_in_hour: INTEGER
        -- Number of seconds in an hour
Seconds_in_day: INTEGER
        -- Number of seconds in a day
Milliseconds_in_day: INTEGER
        -- Number of milliseconds in a day
Minutes_in_hour: INTEGER
        -- Number of minutes in an hour
Hours_in_day: INTEGER
        -- Number of hours in a day
feature -- Epoch
Epoch_year: INTEGER
Epoch_month: INTEGER
Epoch_day: INTEGER
        -- Epoch date (1 Jan 1970)
epoch_days (y, m, d: INTEGER): INTEGER
        -- Number of days since epoch date (1 Jan 1970)
    require
        m_large_enough: m >= January
        m_small_enough: m <= December
        d_large_enough: d >= 1
        d_small_enough: d <= days_in_month (m, y)
end -- class DT_GREGORIAN_CALENDAR

Copyright © 2000-2001, Eric Bezault
mailto:
ericb@gobosoft.com
http:
//www.gobosoft.com
Last Updated: 8 April 2001

HomeTocPreviousNext