summaryrefslogtreecommitdiff
path: root/src/simple_time.adb
diff options
context:
space:
mode:
Diffstat (limited to 'src/simple_time.adb')
-rw-r--r--src/simple_time.adb32
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;
+
+