Skip to content

Commit

Permalink
M agpl-trace-file.adb
Browse files Browse the repository at this point in the history
M    agpl-trace-file.ads
M    agpl-calendar-format.adb
M    agpl-calendar-format.ads
  • Loading branch information
mosteo committed Jun 26, 2006
1 parent 7ec4f30 commit afda95b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
26 changes: 25 additions & 1 deletion agpl-calendar-format.adb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ package body Agpl.Calendar.Format is
Put (S (5 .. 6), (Seconds rem 3600) / 60);
Put (S (9 .. 10), Seconds rem 60);
Put (S (13 .. 15),
Integer (D * 1000.0 - Duration (Seconds * 1000)));
Integer (1000.0 * D - Duration (Seconds * 1000)));
if Seconds / 3600 > 99 then
Put (S2, Seconds / 3600);
return Trim (S2, Both) & "h " & S (5 .. S'Last);
Expand Down Expand Up @@ -120,4 +120,28 @@ package body Agpl.Calendar.Format is
return "??:??:??.??";
end Timestamp;

function Datestamp (H : in Ada.Calendar.Time := Ada.Calendar.Clock;
Separator : in Character := '/')
return String
is
-- yyyy.mm.dd
use Ada.Calendar;
package Int_Io is new Text_IO.Integer_IO (Integer);
use Int_Io;
s : String (1 .. 10) := (5 => Separator, 8 => Separator, others => <>);
begin
Put (s (1 .. 4), Year (H));
Put (s (6 .. 7), Month (H));
Put (s (9 .. 10), Day (H));
for i in s'Range loop
if s (i) = ' ' then
s (i) := '0';
end if;
end loop;
return s;
exception
when others =>
return "????" & Separator & "??" & Separator & "?";
end Datestamp;

end Agpl.Calendar.Format;
14 changes: 5 additions & 9 deletions agpl-calendar-format.ads
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,17 @@ with Ada.Calendar;

package Agpl.Calendar.Format is

------------------------------------------------------------------------
-- Image --
------------------------------------------------------------------------
-- Returns a beautified duration in hours, minutes, seconds, ms
function Image (D : in Duration) return String;

------------------------------------------------------------------------
-- Hour --
------------------------------------------------------------------------
-- Returns as a string hh:mm:ss
function Hour (T : in Ada.Calendar.Time) return String;

------------------------------------------------------------------------
-- Timestamp --
------------------------------------------------------------------------
-- Returns the date as yyyy/mm/dd
function Datestamp (H : in Ada.Calendar.Time := Ada.Calendar.Clock;
Separator : in Character := '/')
return String;

-- Returns the time as hh:mm:ss:dd
function Timestamp (h : Ada.Calendar.Time := Ada.Calendar.Clock)
return String;
Expand Down
4 changes: 3 additions & 1 deletion agpl-trace-file.adb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ package body Agpl.Trace.File is

procedure Set_File
(This : in out Object;
Name : in String := Calendar.Format.Timestamp & ".log";
Name : in String := Command_Line.Program_Name & "." &
Calendar.Format.Datestamp (Separator =>'.') &"."&
Calendar.Format.Timestamp & ".log";
Mode : in Modes := Append)
is
begin
Expand Down
2 changes: 1 addition & 1 deletion agpl-trace-file.ads
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ package Agpl.Trace.File is
procedure Set_File
(This : in out Object;
Name : in String := Command_Line.Program_Name & "." &
Calendar.Format.Datestamp & "." &
Calendar.Format.Datestamp (Separator =>'.') &"."&
Calendar.Format.Timestamp & ".log";
Mode : in Modes := Append);

Expand Down

0 comments on commit afda95b

Please sign in to comment.