comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
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	[thread overview]
Message-ID: <sl31nr$li0$1@dont-email.me> (raw)
In-Reply-To: <5dcbccb3-1e2b-42cb-91e1-4be31442a647n@googlegroups.com>

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

  reply	other threads:[~2021-10-24  7:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-05  6:56 Trivial question: how to avoid confusing sec, min, hour and day in a program? reinert
2021-09-05  7:27 ` Dmitry A. Kazakov
2021-09-05 12:42   ` Niklas Holsti
2021-09-06  7:20   ` ldries46
2021-09-06  9:47     ` Dmitry A. Kazakov
2021-09-06 13:06       ` ldries46
2021-09-06 13:43         ` J-P. Rosen
2021-09-06 14:13           ` ldries46
2021-09-06 15:10             ` Dennis Lee Bieber
2021-09-06 15:55       ` AdaMagica
2021-09-08 22:00     ` Shark8
2021-10-24  6:52   ` reinert
2021-10-24  7:24     ` J-P. Rosen [this message]
2021-10-24 10:39       ` Jeffrey R.Carter
2021-10-24 10:08     ` G.B.
2021-10-24 10:48     ` Simon Wright
2021-10-24 12:09     ` Björn Lundin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox