* How to calculate the number of seconds since January 1st, 1970 ?
@ 2002-04-02 9:24 P. Renaud
2002-04-02 12:00 ` Joachim Schröer
2002-04-02 14:03 ` David C. Hoos
0 siblings, 2 replies; 5+ messages in thread
From: P. Renaud @ 2002-04-02 9:24 UTC (permalink / raw)
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 ?
Thanks for your help.
P. Renaud
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to calculate the number of seconds since January 1st, 1970 ?
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
1 sibling, 0 replies; 5+ messages in thread
From: Joachim Schröer @ 2002-04-02 12:00 UTC (permalink / raw)
P. Renaud wrote:
> 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 ?
>
> Thanks for your help.
>
> P. Renaud
>
Hi,
you could download
www.adapower.com\schroer\lib-src.zip
Use one of the "-" functions in package utilities.calendar_utilities.
The functions may be used to calculate what you are looking for.
The package is a version of Grady Booch's calendar_utilities with some
additional features.
Best regards
J. Schr�er
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to calculate the number of seconds since January 1st, 1970 ?
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
1 sibling, 0 replies; 5+ messages in thread
From: David C. Hoos @ 2002-04-02 14:03 UTC (permalink / raw)
----- 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
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: How to calculate the number of seconds since January 1st, 1970 ?
[not found] <0ad901c1da4f$26cc0160$453ab4d8@sy.com>
@ 2002-04-02 15:09 ` Mário Amado Alves
2002-04-02 18:32 ` tmoran
0 siblings, 1 reply; 5+ messages in thread
From: Mário Amado Alves @ 2002-04-02 15:09 UTC (permalink / raw)
> . . .
> What compiler are you using, for which the resulting Duration value is
out of range?
Indeed, GNAT's Duration spans circa 6 centuries:
type Duration is delta 0.000000001
range -((2 ** 63 - 1) * 0.000000001) ..
+((2 ** 63 - 1) * 0.000000001);
for Duration'Small use 0.000000001;
So the original poster must be using either
- another compiler
- bad data
- good data from the Howard Foundation ;-)
Cheers,
--MAA
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: How to calculate the number of seconds since January 1st, 1970 ?
2002-04-02 15:09 ` Mário Amado Alves
@ 2002-04-02 18:32 ` tmoran
0 siblings, 0 replies; 5+ messages in thread
From: tmoran @ 2002-04-02 18:32 UTC (permalink / raw)
>Indeed, GNAT's Duration spans circa 6 centuries:
But the ARM only requires Duration to include -86400.0 .. 86400.0
>So the original poster must be using either
>
> - another compiler
So he can either lock himself into ACT as a vendor, or use one of the
previously mentioned utilities (e.g. see www.adapower.com).
Of course Ada.Calendar.Clock returns a rather arbitrary number dependent
on the time zone and the accuracy of the system operator's watch and
the accuracy of the computer's clock, so it's a rather nominal source
for the actual number of seconds since 1/1/70 00:00:00
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-04-02 18:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
[not found] <0ad901c1da4f$26cc0160$453ab4d8@sy.com>
2002-04-02 15:09 ` Mário Amado Alves
2002-04-02 18:32 ` tmoran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox