From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cb708cd6d4788d36 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-04-02 06:04:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!deine.net!freenix!enst!enst.fr!not-for-mail From: "David C. Hoos" Newsgroups: comp.lang.ada Subject: Re: How to calculate the number of seconds since January 1st, 1970 ? Date: Tue, 2 Apr 2002 08:03:22 -0600 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <92694761.0204020124.13aaf9d@posting.google.com> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1017756243 75096 137.194.161.2 (2 Apr 2002 14:04:03 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Tue, 2 Apr 2002 14:04:03 +0000 (UTC) Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:21991 Date: 2002-04-02T08:03:22-06:00 ----- Original Message ----- From: "P. Renaud" Newsgroups: comp.lang.ada To: 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 >