summaryrefslogtreecommitdiff
path: root/records/src/records.adb
blob: f3c60ae6f932f8610034e868e9ea3cfe18eafb4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
with Ada.Text_IO; use Ada.Text_IO;

procedure Records is

  type Month_Type is (January, February, March, April, May, June, July, August,
                      September, October, November, December);

  type Date is record
    Day   : Integer range 1 .. 31 := 1;
    Month : Month_Type := January;
    Year  : Integer := 1970;
  end record;

  function To_String (D : Date) return String is
  begin
    return Month_Type'Image (D.Month) & " " & Integer'Image (D.Day) & ", " &
      Integer'Image(D.Year);
  end To_String;

  Epoch : Date;
  Ada_Birthday : Date := (10, December, 1815);
  Leap_Day_2020 : Date := (29, February, 2020);

begin
  Put_Line ("Epoch is " & To_String (Epoch));
  Put_Line ("Ada's birthday is " & To_String (Ada_Birthday));
  Put_Line ("Leap day 2020: " & To_String (Leap_Day_2020));
end Records;