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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3c620ebecf1e16d4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews2.google.com!not-for-mail From: gautier_niouzes@hotmail.com (Gautier) Newsgroups: comp.lang.ada Subject: Re: ADA.CALENDAR and midnight Date: 6 Aug 2004 00:34:46 -0700 Organization: http://groups.google.com Message-ID: <17cd177c.0408052334.2ec44517@posting.google.com> References: <2nelqrF21jaU1@uni-berlin.de> NNTP-Posting-Host: 213.173.163.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1091777686 1013 127.0.0.1 (6 Aug 2004 07:34:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 6 Aug 2004 07:34:46 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:2594 Date: 2004-08-06T00:34:46-07:00 List-Id: Brian May : > Going back to me to_string function, are there any packages (GPL > compatible licence preferred) for displaying formatted output? For > instance, my function would display "12:0:0", it would be preferred if > I could display it as "12:00:00". I have a package called > "Formatted_Output" by "Eugene Nonko, cm@liceum.secna.ru", but the > license is unclear. I am not convinced the approach taken is ideal > either. Ideally, I would prefer not to have to reinvent the wheel. For obtaining all heading '0's you need there is a simple trick (here, a Time_log function of mine, also 16-bit and Ada83 compatible): with Calendar; function Time_log return String is use Calendar; subtype Sec_int is Long_Integer; -- must contain 86_400 T : Time:= Clock; m, s : Sec_int; begin s := Sec_int( Seconds(T) ); m := s / 60; declare -- + 100: trick for obtaining 0x sY : constant String:= Integer'Image( Year(T)); sM : constant String:= Integer'Image( Month(T) + 100); sD : constant String:= Integer'Image( Day(T) + 100); shr: constant String:= Sec_int'Image( m / 60 + 100); smn: constant String:= Sec_int'Image( m mod 60 + 100); ssc: constant String:= Sec_int'Image( s mod 60 + 100); begin return sY( sY'Last-3 .. sY'Last ) & '/' & -- not Year 10'000 compliant. sM( sM'Last-1 .. sM'Last ) & '/' & sD( sD'Last-1 .. sD'Last ) & " " & shr( shr'Last-1 .. shr'Last ) & ':' & smn( smn'Last-1 .. smn'Last ) & ':' & ssc( ssc'Last-1 .. ssc'Last ); end; end Time_log; HTH ________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!