From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE, T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!watserv1!watmath!att!ucbvax!elcgl.epfl.ch!madmats From: madmats@elcgl.epfl.ch ("", Mats Weber) Newsgroups: comp.lang.ada Subject: Limits on type Duration and package Calendar Message-ID: Date: 8 Jul 90 18:46:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet List-Id: RFC-822-Headers: Received: from elcgl.epfl.ch by SIC.Epfl.CH with VMSmail ; Sun, 8 Jul 90 19:46:19 N X-ST-Vmsmail-To: gw::"info-ada@ajpo.sei.cmu.edu" ================== Marshall Brinn (mbrinn@bbn.com) writes: >[stuff deleted...] >Any suggestions on the "Standard" ADA way to deal with time gaps > 1 day >would be appreciated. There are good reasons for not requiring the type Duration to cover more that one day (fixed point type implementable using one machine-word on most CPUs). However, I think that Calendar should have defined another Duration type that enables handling longer time intervals, as is done in the package spec below. The complete portable implementation source code may be obtained on request by sending e-mail to: Mats Weber Swiss Federal Institute of Technology EPFL DI LGL 1015 Lausanne Switzerland E-mail : madmats@elcgl.epfl.ch phone : +41 21 693 52 92 fax : +41 21 693 39 09 ------------------------------------------------------------------------- -- ADDITIONAL CALENDAR FUNCTIONS ----------------------------- -- Creation : 19-JAN-1987 by Mats Weber. with Calendar; use Calendar; package Extended_Calendar is ------------------------- type Long_Duration is private; type Day_Interval is range -366 * Year_Number'Last..366 * Year_Number'Last; subtype Natural_Day_Interval is Day_Interval range 0..Day_Interval'Last; type Duration_Sign is ('+', '-'); function To_Long_Duration (Days : Natural_Day_Interval; Seconds : Day_Duration; Sign : Duration_Sign := '+') return Long_Duration; function To_Long_Duration (Seconds : Day_Duration; Sign : Duration_Sign := '+') return Long_Duration; function To_Long_Duration (Days : Natural_Day_Interval; Sign : Duration_Sign := '+') return Long_Duration; function Days (Delta_Time : Long_Duration) return Natural_Day_Interval; function Seconds (Delta_Time : Long_Duration) return Day_Duration; function Sign (Delta_Time : Long_Duration) return Duration_Sign; function To_Duration (Delta_Time : Long_Duration) return Duration; function Zero return Long_Duration; function "+" (A : Long_Duration) return Long_Duration; function "-" (A : Long_Duration) return Long_Duration; function "abs" (A : Long_Duration) return Long_Duration; function "+" (A, B : Long_Duration) return Long_Duration; function "-" (A, B : Long_Duration) return Long_Duration; function "*" (N : Integer; A : Long_Duration) return Long_Duration; function "*" (A : Long_Duration; N : Integer) return Long_Duration; function "/" (A : Long_Duration; N : Integer) return Long_Duration; function "<" (A, B : Long_Duration) return Boolean; function "<=" (A, B : Long_Duration) return Boolean; function ">" (A, B : Long_Duration) return Boolean; function ">=" (A, B : Long_Duration) return Boolean; function "+" (T : Time; A : Long_Duration) return Time; function "+" (A : Long_Duration; T : Time) return Time; function "-" (T : Time; A : Long_Duration) return Time; function "-" (T1, T2 : Time) return Long_Duration; -- Will raise TIME_ERROR if no valid time value can be returned. type Week_Day is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); function Succ (Day : Week_Day) return Week_Day; function Pred (Day : Week_Day) return Week_Day; function Day_Of_Week (Date : Time := Clock) return Week_Day; function Day_Of_Week (Year : Year_Number; Month : Month_Number; Day : Day_Number) return Week_Day; private type Long_Duration is record Days : Natural_Day_Interval; Seconds : Day_Duration; Sign : Duration_Sign; end record; end Extended_Calendar;