From: "David C. Hoos" <david.c.hoos.sr@ada95.com>
Subject: Re: How to calculate the number of seconds since January 1st, 1970 ?
Date: Tue, 2 Apr 2002 08:03:22 -0600
Date: 2002-04-02T08:03:22-06:00 [thread overview]
Message-ID: <mailman.1017756242.3838.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: 92694761.0204020124.13aaf9d@posting.google.com
----- Original Message -----
From: "P. Renaud" <patrick.renaud@transport.alstom.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: Tuesday, April 02, 2002 3:24 AM
Subject: How to calculate the number of seconds since January 1st, 1970 ?
> Hi all,
>
> I have to calculate the number of seconds since January 1st, 1970
> 00:00.
>
> I tried using the Calendar package but it always fails with the
> Time_Error exception (the minus operator used to calculate the
> difference between the current date/time and the reference date/time
> is greater than the duration type limit).
>
> How can I do to obtain the correct result ?
>
What's wrong with this?
with Ada.Calendar;
with Ada.Text_IO;
procedure Seconds is
Elapsed_Time : Duration;
Unix_Epoch : constant Ada.Calendar.Time :=
Ada.Calendar.Time_Of
(Year => 1970,
Month => 1,
Day => 1,
Seconds => 0.0);
use type Ada.Calendar.Time;
begin
Elapsed_Time := Ada.Calendar.Clock - Unix_Epoch;
Ada.Text_IO.Put_Line (Duration'Image (Elapsed_Time));
end Seconds;
What compiler are you using, for which the resulting Duration
value is out of range?
David Hoos
> Thanks for your help.
>
> P. Renaud
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>
next prev parent reply other threads:[~2002-04-02 14:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-02 9:24 How to calculate the number of seconds since January 1st, 1970 ? P. Renaud
2002-04-02 12:00 ` Joachim Schröer
2002-04-02 14:03 ` David C. Hoos [this message]
[not found] <0ad901c1da4f$26cc0160$453ab4d8@sy.com>
2002-04-02 15:09 ` Mário Amado Alves
2002-04-02 18:32 ` tmoran
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox