Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ada > #49854

Re: Trivial question: how to avoid confusing sec, min, hour and day in a program?

From Simon Wright <simon@pushface.org>
Newsgroups comp.lang.ada
Subject Re: Trivial question: how to avoid confusing sec, min, hour and day in a program?
Date 2021-10-24 11:48 +0100
Organization Aioe.org NNTP Server
Message-ID <ly1r4absw7.fsf@pushface.org> (permalink)
References <c1e4f8bf-f3f0-4a14-b057-37f330461f9cn@googlegroups.com> <sh1rha$14d6$1@gioia.aioe.org> <5dcbccb3-1e2b-42cb-91e1-4be31442a647n@googlegroups.com>

Show all headers | View raw


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.

Back to comp.lang.ada | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Trivial question: how to avoid confusing sec, min, hour and day in a program? reinert <reinkor@gmail.com> - 2021-09-04 23:56 -0700
  Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2021-09-05 09:27 +0200
    Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Niklas Holsti <niklas.holsti@tidorum.invalid> - 2021-09-05 15:42 +0300
    Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? ldries46 <bertus.dries@planet.nl> - 2021-09-06 09:20 +0200
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2021-09-06 11:47 +0200
        Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? ldries46 <bertus.dries@planet.nl> - 2021-09-06 15:06 +0200
          Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "J-P. Rosen" <rosen@adalog.fr> - 2021-09-06 15:43 +0200
            Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? ldries46 <bertus.dries@planet.nl> - 2021-09-06 16:13 +0200
              Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2021-09-06 11:10 -0400
        Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? AdaMagica <christ-usch.grein@t-online.de> - 2021-09-06 08:55 -0700
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Shark8 <onewingedshark@gmail.com> - 2021-09-08 15:00 -0700
    Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? reinert <reinkor@gmail.com> - 2021-10-23 23:52 -0700
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "J-P. Rosen" <rosen@adalog.fr> - 2021-10-24 09:24 +0200
        Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not> - 2021-10-24 12:39 +0200
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? "G.B." <bauhaus@notmyhomepage.invalid> - 2021-10-24 12:08 +0200
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Simon Wright <simon@pushface.org> - 2021-10-24 11:48 +0100
      Re: Trivial question: how to avoid confusing sec, min, hour and day in a program? Björn Lundin <b.f.lundin@gmail.com> - 2021-10-24 14:09 +0200

csiph-web