From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Date: Sun, 24 Oct 2021 09:24:46 +0200 Organization: Adalog Message-ID: References: <5dcbccb3-1e2b-42cb-91e1-4be31442a647n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 24 Oct 2021 07:24:43 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="72f300d732b5b28c170baeb80b9d0c7a"; logging-data="22080"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/0qLG347mlwqdUXL6RzUF" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Cancel-Lock: sha1:i9NtaJDcrQfZ7zQUMcprLDVMGBE= In-Reply-To: <5dcbccb3-1e2b-42cb-91e1-4be31442a647n@googlegroups.com> Content-Language: fr Xref: reader02.eternal-september.org comp.lang.ada:63071 List-Id: Le 24/10/2021 à 08:52, reinert a écrit : > Ada seems to guarantee that Duration covers 24 hours (?). What you do when you need to represent for example 5 years? Ada /guarantees/ at least 24 hours, since subtype Day_Duration corresponds to one day. In practice, Duration is much bigger. There is no requirement for it, since it obviously depends on the implementation. With Gnat, the following program: with Text_Io; use Text_Io; procedure Test_Duration is package Duration_Io is new Fixed_Io (Duration); use Duration_Io; begin null; Put ("duration'last:"); Put (Duration'Last); New_Line; Put ("days:") ; Put (Duration'Last / 86400); New_Line; Put ("years:") ; Put (Duration'Last / 86400 / 365.25); New_Line; end; gives: duration'last: 9223372036.854775807 days: 106751.991167300 years: 292.271023045 -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52 https://www.adalog.fr