with Ada.Calendar;
package Dates is
------------------------------------------------------------------
--|
--| specification for package to represent calendar dates
--|
--| Author: Michael B. Feldman, The George Washington University
--| Last Modified: September 1995
--|
------------------------------------------------------------------
subtype YearNumber is Ada.Calendar.Year_Number;
subtype MonthNumber is Ada.Calendar.Month_Number;
subtype DayNumber is Ada.Calendar.Day_Number;
subtype JulianDay is Positive range 1..366;
subtype WeekDay is Positive range 1..7;
type Date is private;
-- exported exception
Date_Error : exception;
-- constructors
function Today return Date;
-- Pre: none
-- Post: returns the current date
function MakeDate(Year : YearNumber;
Month : MonthNumber;
Day : DayNumber) return Date;
-- Pre: Year, Month, and Day are defined
-- Post: returns a Date object
-- Raises: Date_Error if Year, Month, and Day do not
-- form a valid date (e.g. 6/31/93 or 2/29/93)
-- selectors
function Year (Right: Date) return YearNumber;
function Month (Right: Date) return MonthNumber;
function DayOfMonth (Right: Date) return DayNumber;
function DayOfYear (Right: Date) return JulianDay;
function DayOfWeek (Right: Date) return WeekDay;
-- Pre: Right is defined
-- Post: these return the corresponding parts of the Date object
-- comparison operators
function "<" (Left, Right: Date) return Boolean;
function "<=" (Left, Right: Date) return Boolean;
function ">" (Left, Right: Date) return Boolean;
function ">=" (Left, Right: Date) return Boolean;
-- Pre: Left and Right are defined
-- Post: these return the result of the corresponding comparison
-- arithmetic operators
function "+" (Left: Date; Right: JulianDay) return Date;
function "+" (Left: JulianDay; Right: Date) return Date;
function "-" (Left: Date; Right: JulianDay) return Date;
-- Pre: the arguments are defined
-- Post: return a Date in the near future or recent past
private
type Date is record
Year: YearNumber := YearNumber'First;
DayOfYear: JulianDay := 1;
end record;
end Dates;