From 727e3c59346da4f91284b34b4c18f2e0ba155e53 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 9 Aug 2025 16:03:28 +0200 Subject: Initial commit --- records/src/records.adb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 records/src/records.adb (limited to 'records/src/records.adb') diff --git a/records/src/records.adb b/records/src/records.adb new file mode 100644 index 0000000..f3c60ae --- /dev/null +++ b/records/src/records.adb @@ -0,0 +1,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; -- cgit v1.2.3