|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: B T
Length: 8117 (0x1fb5)
Types: TextFile
Names: »B«
└─⟦180fe333a⟧ Bits:30000405 8mm tape, Rational 1000, SW CATALOG, 10_20_0
└─⟦180fe333a⟧ Bits:30000537 8mm tape, Rational 1000, SW Catalog 10_20_0
└─⟦5cb1d1d7f⟧ »DATA«
└─⟦3b1ee7bd8⟧
└─⟦this⟧
with Text_Io, Calendar, Time_Library_1;
---------------------------
package body Time_Library_2 is
---------------------------
--| Overview
--| TimeLib contains procedures and functions for getting, putting,
--| and calculating times, dates, and durations. It augments the
--| predefined library package Calendar to simplify IO and provide
--| additional time routines common to all Ada Test and Evaluation
--| Tool Set (ATETS) tools.
--| Requires
--| All procedures and functions that perform IO use use the
--| predefined library package Text_IO and require that the
--| specified file be opened by the calling program prior to use.
--| All times and durations must be of types declared in the
--| predefined library package Calendar.
--| Errors
--| No error messages or exceptions are raised by any of the TimeLib
--| procedures and functions. However, any Text_IO and Calendar
--| exceptions that may be raised are allowed to pass, unhandled,
--| back to the calling program.
--| N/A: Raises, Modifies
-- Version : 1.0
-- Author : Jeff England
-- Initial Release : 05/21/85
package Int_Io is new Text_Io.Integer_Io (Integer);
package Time_Io is new Text_Io.Fixed_Io (Calendar.Day_Duration);
Timing_Method : Time_Library_1.
Timing_Type; --| Methods are Raw and Wall_Clock
------------------
procedure Get_Time_Of_Day
(--| Get the time of day from the file
Fyle : in Text_Io.File_Type; --| The input file
Seconds : out
Calendar.Day_Duration --| The time read from fyle
) is
--| Effects
--| Gets and returns the time of day from the file.
--| Requires
--| Fyle must have been previously opened by the calling program.
--| The time must have been previously put to fyle in the format
--| output by Put_Time_of_Day.
--| N/A: Raises, Modifies, Errors
use Time_Library_1;
--| For Timing_Type
use Calendar; --| For "+" of Times and Day_Durations
subtype Hour_Number is Integer range 0 .. 23;
subtype Minute_Number is Integer range 0 .. 59;
Hrs : Hour_Number;
Mins : Minute_Number;
Secs : Calendar.Day_Duration;
Temp_Ch : Character; -- temporary storage for field delimiter
begin
if Timing_Method = Raw then
Time_Io.Get (Fyle, Seconds);
else
-- Timing Method is Wall_Clock
Int_Io.Get (Fyle, Hrs, 2);
Text_Io.Get (Fyle, Temp_Ch);
Int_Io.Get (Fyle, Mins, 2);
Text_Io.Get (Fyle, Temp_Ch);
Time_Io.Get (Fyle, Secs, 5);
Seconds := Secs + Day_Duration (Hrs * 3600 + Mins * 60);
end if;
end Get_Time_Of_Day;
------------------
procedure Get_Time ( --| Get the time from the file
Fyle : in Text_Io.File_Type; --| The input file
Date : out Calendar.Time --| The time read from fyle
) is
--| Effects
--| Gets and returns the time from the file.
--| Requires
--| Fyle must have been previously opened by the calling program.
--| The time must have been previously put to fyle in the format
--| output by Put_Time.
--| N/A: Raises, Modifies, Errors
use Time_Library_1; --| For Timing_Type
use Calendar; --| For "+" of Times and Day_Durations
Year : Calendar.Year_Number; -- range 1901 .. 2099
Month : Calendar.Month_Number;-- range 1 .. 12
Day : Calendar.Day_Number; -- range 1 .. 31
Seconds : Calendar.Day_Duration;
Temp_Ch : Character; -- temporary storage for field delimiter
Short_Year : Integer range 0 .. 99; -- a 2 digit of the year
begin
Int_Io.Get (Fyle, Month, 2);
Text_Io.Get (Fyle, Temp_Ch);
Int_Io.Get (Fyle, Day, 2);
Text_Io.Get (Fyle, Temp_Ch);
Int_Io.Get (Fyle, Short_Year, 2);
Text_Io.Get (Fyle, Temp_Ch);
-- The following assignment will produce an invalid year after 2084
-- However, it enables the use of 2 digit year numbers in the log
-- file and will still produce a valid date when the date is written
-- in one year and read back in another year.
if Short_Year < 85 then
Year := Short_Year + 2000;
else
Year := Short_Year + 1900;
end if;
Get_Time_Of_Day (Fyle, Seconds);
Date := Calendar.Time_Of (Year, Month, Day, 0.0) + Seconds;
end Get_Time;
-----------------
function Maximum (--| Return the MAXIMUM of two Day_Durations
Time1, Time2 : in
Calendar.Day_Duration --| The two times to be compared
) return Calendar.Day_Duration is
--| Effects
--| Compares Time1 to Time2 and returns the MAXIMUM of the two times.
--| N/A: Raises, Requires, Modifies, Errors
use Calendar;
begin
if Time1 > Time2 then
return Time1;
else
return Time2;
end if;
end Maximum;
-----------------
function Minimum (--| Return the MINIMUM of two Day_Durations
Time1, Time2 : in
Calendar.Day_Duration --| The two times to be compared
) return Calendar.Day_Duration is
--| Effects
--| Compares Time1 to Time2 and returns the MINIMUM of the two times.
--| N/A: Raises, Requires, Modifies, Errors
use Calendar;
begin
if Time1 > Time2 then
return Time2;
else
return Time1;
end if;
end Minimum;
--------------------
function Weekday_Of ( --| Return the day of week for the specified date
Date : in Calendar.Time --| The date to be converted
) return Weekdays is
--| Effects
--| Returns the day of week (Sunday..Saturday) for the specified date
--| N/A: Raises, Requires, Modifies, Errors
use Calendar;
Y : Integer; -- A temporary variable for the year. A short name
-- makes the algorithm more readable.
Offset : constant array (1 .. 12) of Integer :=
(1, 4, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5);
begin
if Month (Date) = 1 or Month (Date) = 2 then
Y := Year (Date) - 1901;
else
Y := Year (Date) - 1900;
end if;
return Weekdays'Val ((Offset (Month (Date)) + Y +
Y / 4 + Day (Date)) mod 7);
end Weekday_Of;
--------------------
function Weekday_Of ( --| Return the day of week for the specified date
Date : in Calendar.Time --| The date to be converted
) return String is
--| Effects
--| Returns the day of week (Sunday..Saturday) for the specified date
--| N/A: Raises, Requires, Modifies, Errors
begin
return Weekdays'Image (Weekday_Of (Date));
end Weekday_Of;
-------------------
procedure Timing_Is
(--| Sets the timing method for times recorded in
--| the logfile to Raw or Wall_Clock
Time_Type : in Time_Library_1.Timing_Type
--| The timing method used to record timing data in the logfile
) is
--| Effects
--| Sets the timing method for GETting times from the logfile to
--| correspond to the timing method used for recording times in
--| the logfile by the Run Time Monitor (RTM). Timing methods are
--| RAW and WALL_CLOCK.
--| N/A: Raises, Requires, Modifies, Errors
begin
Timing_Method := Time_Type;
end Timing_Is;
end Time_Library_2;