From: Simon Wright <simon@pushface.org>
Subject: Re: Trivial question: how to avoid confusing sec, min, hour and day in a program?
Date: Sun, 24 Oct 2021 11:48:24 +0100 [thread overview]
Message-ID: <ly1r4absw7.fsf@pushface.org> (raw)
In-Reply-To: 5dcbccb3-1e2b-42cb-91e1-4be31442a647n@googlegroups.com
reinert <reinkor@gmail.com> writes:
> Ada seems to guarantee that Duration covers 24 hours (?). What you do
> when you need to represent for example 5 years?
This must depend on your use case.
I'd imagine you want to arrange for some event to happen 5 years in the
future. The 'natural' way to do this might be, in a task,
delay until Ada.Calendar.Clock + Duration'({5 years});
but this comes up against two problems: first, as you note, that long a
duration might not work, and second, the computer is almost certain to
have been restarted by then, losing this task.
The second problem could be solved by, e.g., keeping a backed-up
time-ordered queue of events to be processed, with a task that delays
until the next event is due.
As for the first -- I think you may need to make an appropriate
Duration'Last part of your compiler selection criteria.
next prev parent reply other threads:[~2021-10-24 10:48 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
2021-10-24 10:39 ` Jeffrey R.Carter
2021-10-24 10:08 ` G.B.
2021-10-24 10:48 ` Simon Wright [this message]
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