|
|
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: 8514 (0x2142)
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;
use Text_Io;
with Float_Io;
use Float_Io;
with Integer_Io;
use Integer_Io;
package body Work_Calendar is
----------------------------------------------------------------------
--| NAME: WORK_CALENDAR
--|
--| OVERVIEW:
--| This package provides functions for manipulating time in a
--| work week. It assumes that the date entered is the last day of
--| the work week. This implies that when you are adding hours to a
--| date, time for the weekend is added before the time for work.
--|
--| HISTORY:
--| written by Bonnie Burkhardt March 1985
--|
--| EXCEPTIONS HANDLED:
--| none
----------------------------------------------------------------------
Days_In_Month : array (1 .. 12) of Integer :=
(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
Vacation_Factor : Float :=
Float (52 * Days_In_Week - Days_Off_In_Year) / Float (52 * Days_In_Week);
procedure Calc_Days (Year : in Year_Number) is
begin
-- check if leap year
if (Year mod 400 = 0) or ((Year mod 100 /= 0) and (Year mod 4 = 0)) then
Days_In_Month (2) := 29;
else
Days_In_Month (2) := 28;
end if;
end Calc_Days;
function "+" (Date : in Date_Type; Day : in Integer) return Date_Type is
Total_Days : Integer := Date.Day + Day;
Sum_Date : Date_Type := Date;
begin
loop
-- check if leap year
Calc_Days (Sum_Date.Year);
-- compute the final date
if Total_Days <= Days_In_Month (Sum_Date.Month) then
Sum_Date.Day := Total_Days;
return Sum_Date;
else
-- move into next month
Total_Days := Total_Days - Days_In_Month (Sum_Date.Month);
if Sum_Date.Month < 12 then
Sum_Date.Month := Sum_Date.Month + 1;
else
-- move into next year
Sum_Date.Month := 1;
Sum_Date.Year := Sum_Date.Year + 1;
end if;
end if;
end loop;
end "+";
function "-" (Date : in Date_Type; Day : in Integer) return Date_Type is
Total_Days : Integer := Day;
Dif_Date : Date_Type := Date;
begin
loop
-- check if leap year
Calc_Days (Dif_Date.Year);
-- compute the final date
if Dif_Date.Day - Total_Days > 0 then
Dif_Date.Day := Dif_Date.Day - Total_Days;
return Dif_Date;
else
-- move into previous month
Total_Days := Total_Days - Days_In_Month (Dif_Date.Month);
if Dif_Date.Month > 1 then
Dif_Date.Month := Dif_Date.Month - 1;
else
-- move into previous year
Dif_Date.Month := 12;
Dif_Date.Year := Dif_Date.Year - 1;
end if;
Dif_Date.Day := Days_In_Month (Dif_Date.Month);
end if;
end loop;
end "-";
function "+" (Day : in Integer; Date : in Date_Type) return Date_Type is
begin
return Date + Day;
end "+";
function "+" (Date : in Date_Type; Hours : in Float) return Date_Type is
Total_Days : Integer := 0;
begin
-- if the number of hours is negative, add the positive number of hours
-- to the date
if Hours < 0.0 then
return Date - (-1.0 * Hours);
end if;
-- calculate the number of days to be added
-- the next four lines were added instead of the following commented line
-- TOTAL_DAYS := truncate(HOURS / (HOURS_IN_DAY * VACATION_FACTOR) ) + 1;
Total_Days := Integer (Hours / (Hours_In_Day * Vacation_Factor));
if (Hours / (Hours_In_Day * Vacation_Factor)) > Float (Total_Days) then
Total_Days := Total_Days + 1;
end if;
-- plus weekends
Total_Days :=
Total_Days + (7 - Days_In_Week) *
((Total_Days - Days_In_Week / 2) / Days_In_Week + 1);
-- calculate the final date
return Date + Total_Days;
end "+";
function "+" (Hours : in Float; Date : in Date_Type) return Date_Type is
begin
return Date + Hours;
end "+";
function "-" (Date : in Date_Type; Hours : in Float) return Date_Type is
Total_Days : Integer := 0;
begin
-- if HOURS is negative, add the positive number of hours to the date
if Hours < 0.0 then
return Date + (-1.0 * Hours);
end if;
-- calculate the number of days to be subtracted
-- the next four lines were added instead of the following commented line
-- TOTAL_DAYS := truncate(HOURS / (HOURS_IN_DAY * VACATION_FACTOR) );
Total_Days := Integer (Hours / (Hours_In_Day * Vacation_Factor));
if (Hours / (Hours_In_Day * Vacation_Factor)) < Float (Total_Days) then
Total_Days := Total_Days - 1;
end if;
-- add in the days in the weekends
Total_Days := Total_Days + (7 - Days_In_Week) *
(Total_Days - 1) / Days_In_Week;
return Date - Total_Days;
end "-";
function "-" (Date1, Date2 : in Date_Type) return Float is
Hour : Float := 0.0;
Day : Integer := 0;
Date_1 : Date_Type := Date1;
Date_2 : Date_Type := Date2;
Negative : Boolean := False;
begin
-- if the subtraction of the dates will result in a negative amount of
-- hours, switch the dates and attach the negative sign at the end
if Date_1 < Date_2 then
Date_1 := Date2;
Date_2 := Date1;
Negative := True;
end if;
-- calculate time difference of years and months in days
Calc_Days (Date_2.Year);
if Date_1.Year = Date_2.Year and Date_1.Month = Date_2.Month then
Day := Date_1.Day - Date_2.Day;
else
Day := Days_In_Month (Date_2.Month) - Date_2.Day + 1;
Date_2 := Date_2 + Day;
while Date_1.Year /= Date_2.Year or
Date_1.Month /= Date_2.Month loop
Calc_Days (Date_2.Year);
Day := Day + Days_In_Month (Date_2.Month);
Date_2 := Date_2 + Days_In_Month (Date_2.Month);
end loop;
Day := Day + Date_1.Day - Date_2.Day;
end if;
-- subtract out the number of days on the weekend
Day := Day - (7 - Days_In_Week) * ((Day - 4) / 7 + 1);
-- number of weekends
-- compute the total difference in hours
if Negative then
return -Float (Day) * Hours_In_Day * Vacation_Factor;
else
return Float (Day) * Hours_In_Day * Vacation_Factor;
end if;
end "-";
function "<" (Date1, Date2 : in Date_Type) return Boolean is
begin
if Date1.Year < Date2.Year then
return True;
elsif (Date1.Year = Date2.Year) and (Date1.Month < Date2.Month) then
return True;
elsif (Date1.Year = Date2.Year) and
(Date1.Month = Date2.Month) and (Date1.Day < Date2.Day) then
return True;
else
return False;
end if;
end "<";
function "<=" (Date1, Date2 : in Date_Type) return Boolean is
begin
return not (Date1 > Date2);
end "<=";
function ">" (Date1, Date2 : in Date_Type) return Boolean is
begin
if Date1.Year > Date2.Year then
return True;
elsif (Date1.Year = Date2.Year) and (Date1.Month > Date2.Month) then
return True;
elsif (Date1.Year = Date2.Year) and
(Date1.Month = Date2.Month) and (Date1.Day > Date2.Day) then
return True;
else
return False;
end if;
end ">";
function ">=" (Date1, Date2 : in Date_Type) return Boolean is
begin
return not (Date1 < Date2);
end ">=";
function Valid (Month, Day, Year : in Integer) return Boolean is
begin
if Year in Year_Number and
Month in Month_Number and Day in Day_Number then
Calc_Days (Year);
if Day <= Days_In_Month (Month) then
return True;
end if;
end if;
return False;
end Valid;
end Work_Calendar;