diff options
author | Jed Barber <jjbarber@y7mail.com> | 2017-02-06 02:32:14 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2017-02-06 02:32:14 +1100 |
commit | c2f324ac23ea143dfea308229f0ac0376ed4f745 (patch) | |
tree | ec97a496f1bfc081d93cc852805ee02e68a58fd4 /src/simple_time.adb | |
parent | 1cfb48a9a65f5f57fec5693a1c723f0ec60f5fe1 (diff) |
Most of the Main procedure done, a Simple Time package added
Diffstat (limited to 'src/simple_time.adb')
-rw-r--r-- | src/simple_time.adb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/simple_time.adb b/src/simple_time.adb new file mode 100644 index 0000000..cf1995c --- /dev/null +++ b/src/simple_time.adb @@ -0,0 +1,32 @@ + + +with Ada.Calendar; use Ada.Calendar; +with Ada.Strings; use Ada.Strings; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; + + +package body Simple_Time is + + + function To_String + (Moment : in Time) + return String + is + Raw_Secs : Day_Duration := Seconds (Moment); + + Hours : Integer := Integer (Raw_Secs) / 3600; + Minutes : Integer := (Integer (Raw_Secs) - Hours * 3600) / 60; + Seconds : Duration := Raw_Secs - Duration (Hours) * 3600 - Duration (Minutes) * 60; + begin + return Trim (Year_Number'Image (Year (Moment)), Both) & "-" & + Trim (Month_Number'Image (Month (Moment)), Both) & "-" & + Trim (Day_Number'Image (Day (Moment)), Both) & " " & + Trim (Integer'Image (Hours), Both) & ":" & + Trim (Integer'Image (Minutes), Both) & ":" & + Trim (Duration'Image (Seconds), Both); + end To_String; + + +end Simple_Time; + + |