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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: How to convert an Fixed_Point to to an Integer ? Date: 1996/12/23 Message-ID: #1/1 X-Deja-AN: 205604907 references: <01bbf058$cbdbf980$LocalHost@jerryware> <1996Dec23.072835.1@eisner> organization: New York University newsgroups: comp.lang.ada Date: 1996-12-23T00:00:00+00:00 List-Id: In article <01bbf058$cbdbf980$LocalHost@jerryware>, "Jerry van Dijk" writes: > The question really is: how do I convert an Ada.Calendar.Time (ie a > Duration, ie a ordinary fixed_point type) to an Integer representing > the nearest number of seconds. Well obviously Time is really a private type, so you are talking about doing something very implementation dependent and nasty here. Presumably you are using GNAT, and have taken an "illegal" peek at the private part of Calendar, where sure enough Time is a derived type of Duration. You will have to use Unchecked conversion to a type that has exactly the same range and delta as duration, you could use duration itself for this purpose. Then just do a normal conversion to seconds and you have the result (the number of seconds since the base, which is often, but not always, the Unix epoch at the start of 1970). But really, you should ask yourself if you want to do this. The resulting code is highly non-portable and conceptually wrong.