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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b1850e397df49d95 X-Google-Attributes: gid103376,public From: "Norman H. Cohen" Subject: Re: How to convert an Fixed_Point to to an Integer ? Date: 1996/12/24 Message-ID: <32C02A1E.6268@watson.ibm.com>#1/1 X-Deja-AN: 205819722 references: <01bbf058$cbdbf980$LocalHost@jerryware> <1996Dec23.072835.1@eisner> <01bbf179$0c4361e0$9b2d5c8b@jerryware> content-type: text/plain; charset=us-ascii organization: IBM Thomas J. Watson Research Center mime-version: 1.0 reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; I) Date: 1996-12-24T00:00:00+00:00 List-Id: Robert Dewar wrote: > The proper way to get the number of seconds from the epoch to now is > > Integer (Calendar.Clock - Epoch_Time); > > where Epoch_Time is a constant declared as something like > > Epoch_Time : constant Time := Calendar.Time_Of (1970,1,1,0.0); > > This approach is clean, and correct Ada and completely portable. Well, it was completely portable on New Year's Day in 1970, but hasn't been since then, since Calendar.Clock - Epoch_Time is of type Duration, whose range is allowed to be as small as -86_400.0 .. 86_400.0, i.e. plus or minus one day (RM 9.6(27)). (Then again, before 1983, I suppose ANY Ada program was vacuously portable to all existing Ada compilers! ;-) ) -- Norman H. Cohen mailto:ncohen@watson.ibm.com http://www.research.ibm.com/people/n/ncohen