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,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e5e856194119d814 X-Google-Attributes: gid103376,public From: mfeldman@seas.gwu.edu (Michael Feldman) Subject: Re: how to handle date and time Date: 1996/10/29 Message-ID: <556f9v$ph8@felix.seas.gwu.edu>#1/1 X-Deja-AN: 193075343 references: <3270C5FD.13108478@3wis.nl> organization: George Washington University newsgroups: comp.lang.ada Date: 1996-10-29T00:00:00+00:00 List-Id: In article <3270C5FD.13108478@3wis.nl>, Noam Kloos wrote: >Hello, how can I get the current time of my system. Im using Gnat for >Linux. >I guess its in the Calendar packgae but i have not found its specs. Correct. >There is a package Julian date but it does not handle time. That's not a standard package; where did you find it? Time of day is in Ada.Calendar. Here's a program that uses the desired operations. Feel free to use it but do not remove the block comment at the beginning. The program was designed so that the average first-semester student can understand it, so it's rather elementary in form, but it does illustrates some of the operations. You really should get an electronic copy of the RM from the web. The html version at www.adahome.com is quite nice. Mike Feldman --- WITH Ada.Text_IO; WITH Ada.Integer_Text_IO; WITH Ada.Calendar; PROCEDURE Time_of_Day IS ------------------------------------------------------------------ --| Displays the current time in hh:mm:ss form, 24-hour clock --| Author: Michael B. Feldman, The George Washington University --| Last Modified: July 1995 ------------------------------------------------------------------ TYPE DayInteger IS RANGE 0..86400; CurrentTime : Ada.Calendar.Time; SecsPastMidnight : DayInteger; MinsPastMidnight : Natural; Secs : Natural; Mins : Natural; Hrs : Natural; BEGIN -- Time_of_Day CurrentTime := Ada.Calendar.Clock; SecsPastMidnight := DayInteger(Ada.Calendar.Seconds(CurrentTime)); MinsPastMidnight := Natural(SecsPastMidnight/60); Secs := Natural(SecsPastMidnight REM 60); Mins := MinsPastMidnight REM 60; Hrs := MinsPastMidnight / 60; Ada.Text_IO.Put(Item => "The current time is "); Ada.Integer_Text_IO.Put (Item => Hrs, Width => 1); Ada.Text_IO.Put (Item => ':'); IF Mins < 10 THEN Ada.Text_IO.Put (Item => '0'); END IF; Ada.Integer_Text_IO.Put (Item => Mins, Width => 1); Ada.Text_IO.Put (Item => ':'); IF Secs < 10 THEN Ada.Text_IO.Put (Item => '0'); END IF; Ada.Integer_Text_IO.Put (Item => Secs, Width => 1); END Time_of_Day;