diff options
author | 3gg <3gg@shellblade.net> | 2025-08-09 16:03:28 +0200 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-08-09 16:03:28 +0200 |
commit | 727e3c59346da4f91284b34b4c18f2e0ba155e53 (patch) | |
tree | 807dccd5cba3c6bae2f8d0c9910157e306c6da5b /records/src/records.adb |
Diffstat (limited to 'records/src/records.adb')
-rw-r--r-- | records/src/records.adb | 28 |
1 files changed, 28 insertions, 0 deletions
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 @@ | |||
1 | with Ada.Text_IO; use Ada.Text_IO; | ||
2 | |||
3 | procedure Records is | ||
4 | |||
5 | type Month_Type is (January, February, March, April, May, June, July, August, | ||
6 | September, October, November, December); | ||
7 | |||
8 | type Date is record | ||
9 | Day : Integer range 1 .. 31 := 1; | ||
10 | Month : Month_Type := January; | ||
11 | Year : Integer := 1970; | ||
12 | end record; | ||
13 | |||
14 | function To_String (D : Date) return String is | ||
15 | begin | ||
16 | return Month_Type'Image (D.Month) & " " & Integer'Image (D.Day) & ", " & | ||
17 | Integer'Image(D.Year); | ||
18 | end To_String; | ||
19 | |||
20 | Epoch : Date; | ||
21 | Ada_Birthday : Date := (10, December, 1815); | ||
22 | Leap_Day_2020 : Date := (29, February, 2020); | ||
23 | |||
24 | begin | ||
25 | Put_Line ("Epoch is " & To_String (Epoch)); | ||
26 | Put_Line ("Ada's birthday is " & To_String (Ada_Birthday)); | ||
27 | Put_Line ("Leap day 2020: " & To_String (Leap_Day_2020)); | ||
28 | end Records; | ||