Go to Package Implementation

WITH Ada.Calendar;
PACKAGE Simple_Dates IS
------------------------------------------------------------------
--|
Specification for package to represent calendar dates
--| in a
form convenient for reading and displaying.
--| Author: Michael
B. Feldman, The George
Washington
University
--| Last
Modified: July
1995
------------------------------------------------------------------
 
  TYPE Months IS
    (Jan, Feb, Mar, Apr,
May, Jun, Jul, Aug, Sep, Oct, Nov,
Dec);
 
  -- START NEW
MATERIAL
 
  TYPE Date IS PRIVATE;
  Date_Error :
EXCEPTION; 
 
  PROCEDURE Get(Item: OUT Date; File:
IN Ada.Text_IO.File_Type); 
  -- Pre:  the file exists and is open for
reading
  -- Post:
Reads a date from the file
 
-- Raises: if date is not valid raises
Date_Error
 
  PROCEDURE Put(Item: IN Date; File:
IN Ada.Text_IO.File_Type); 
  -- Pre:  Date is defined, file exists and is
open for writing
  --
Post: Write the date to the
file
 
  -- END NEW
MATERIAL 
 
  PROCEDURE Get(Item: OUT
Date);
  -- Pre:  None
  -- Post: Reads a date in mmm dd
yyyy form, returning it in Item
  --        NEW: Should handle
input
robustly
 
 
  PROCEDURE Put(Item: IN
Date);
  -- Pre:  Item is defined
  -- Post: Displays a date in mmm dd
yyyy form
 
 
FUNCTION Today RETURN Date;
  -- Pre:  None
  -- Post: Returns today's
date
 
PRIVATE
 
  TYPE Date IS RECORD
    Month:
Months;
   
Day:  
Ada.Calendar.Day_Number;
    Year: 
Ada.Calendar.Year_Number;
  END
RECORD;
 
END Simple_Dates;