summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/simple_time.adb22
-rw-r--r--src/simple_time.ads5
-rw-r--r--src/stv.adb6
3 files changed, 25 insertions, 8 deletions
diff --git a/src/simple_time.adb b/src/simple_time.adb
index 6c31a89..f206f13 100644
--- a/src/simple_time.adb
+++ b/src/simple_time.adb
@@ -15,7 +15,7 @@ use
package body Simple_Time is
- function To_String
+ function Image
(Moment : in Time)
return String
is
@@ -27,17 +27,31 @@ package body Simple_Time is
Year_Str : String (1 .. 4);
Month_Str, Day_Str, Hour_Str, Minute_Str : String (1 .. 2);
- Second_Str : String (1 .. 12);
+ Second_Str : String (1 .. 9);
begin
Move (Trim (Year_Number'Image (Year (Moment)), Left), Year_Str, Left, Right, '0');
Move (Trim (Month_Number'Image (Month (Moment)), Left), Month_Str, Left, Right, '0');
Move (Trim (Day_Number'Image (Day (Moment)), Left), Day_Str, Left, Right, '0');
Move (Trim (Integer'Image (Hours), Left), Hour_Str, Left, Right, '0');
Move (Trim (Integer'Image (Minutes), Left), Minute_Str, Left, Right, '0');
- Move (Trim (Duration'Image (Seconds), Left), Second_Str, Left, Right, '0');
+ Move (Image (Seconds), Second_Str, Left, Right, '0');
return Year_Str & '-' & Month_Str & '-' & Day_Str & " " &
Hour_Str & ':' & Minute_Str & ':' & Second_Str;
- end To_String;
+ end Image;
+
+
+
+
+ function Image
+ (Moment : in Duration)
+ return String
+ is
+ Duration_Trim : String := Trim (Duration'Image (Moment), Left);
+ begin
+ -- Drop unnecessary trailing zeros, of which there are always three.
+ -- Is this a Linux-specific thing? Probably.
+ return Duration_Trim (1 .. (Duration_Trim'Length - 3));
+ end Image;
end Simple_Time;
diff --git a/src/simple_time.ads b/src/simple_time.ads
index 1a0b61b..64af076 100644
--- a/src/simple_time.ads
+++ b/src/simple_time.ads
@@ -12,7 +12,10 @@ package Simple_Time is
function Now return Time renames Ada.Calendar.Clock;
- function To_String (Moment : in Time) return String;
+ function Image (Moment : in Time) return String;
+
+
+ function Image (Moment : in Duration) return String;
function "-" (Left, Right : in Time) return Duration renames Ada.Calendar."-";
diff --git a/src/stv.adb b/src/stv.adb
index 2facffa..c10ec2e 100644
--- a/src/stv.adb
+++ b/src/stv.adb
@@ -218,7 +218,7 @@ begin
Start_Time := Simple_Time.Now;
Main_Log := SU.To_Unbounded_String (Output_Dir.all & "/" & "log.txt");
Log_Msg := SU.To_Unbounded_String ("Started election count at " &
- Simple_Time.To_String (Start_Time));
+ Simple_Time.Image (Start_Time));
Create (Log_File, Append_File, SU.To_String (Main_Log));
Put_Line (Log_File, SU.To_String (Log_Msg));
Close (Log_File);
@@ -265,8 +265,8 @@ begin
-- Finish up logging
Finish_Time := Simple_Time.Now;
Log_Msg := SU.To_Unbounded_String
- ("Finished election count at " & Simple_Time.To_String (Finish_Time) & ASCII.LF &
- Duration'Image (Finish_Time - Start_Time) & " seconds elapsed.");
+ ("Finished election count at " & Simple_Time.Image (Finish_Time) & ASCII.LF &
+ Simple_Time.Image (Finish_Time - Start_Time) & " seconds elapsed.");
Open (Log_File, Append_File, SU.To_String (Main_Log));
Put_Line (Log_File, SU.To_String (Log_Msg));
Close (Log_File);