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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.219.225 with SMTP id pr1mr51356894obc.23.1435130057733; Wed, 24 Jun 2015 00:14:17 -0700 (PDT) X-Received: by 10.140.33.202 with SMTP id j68mr567156qgj.41.1435130057623; Wed, 24 Jun 2015 00:14:17 -0700 (PDT) Path: buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!h15no7779434igd.0!news-out.google.com!4ni2626qgh.1!nntp.google.com!z60no2995275qgd.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 24 Jun 2015 00:14:17 -0700 (PDT) In-Reply-To: <9894cde7-2cf8-4060-be65-857812ad7b09@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:120b:2c78:c8e0:d50e:26d9:f97d:d57d; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG NNTP-Posting-Host: 2a02:120b:2c78:c8e0:d50e:26d9:f97d:d57d References: <9894cde7-2cf8-4060-be65-857812ad7b09@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Is there an easier way for this? From: gautier_niouzes@hotmail.com Injection-Date: Wed, 24 Jun 2015 07:14:17 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.giganews.com comp.lang.ada:193758 Date: 2015-06-24T00:14:17-07:00 List-Id: Here from my toolbox - feel free to customize... -- Time_display returns date & time, current or given. -- E.g.: "2013/08/01 05:49:51" -- Useful for a log file or a display of a lengthy operation. -- This is Ada 83 compatible. Format accepted by SQL queries. -- -- Test program in following comment: -- -- with Text_IO,Time_display; -- procedure Test is begin Text_IO.Put(Time_display);end; with Calendar; function Time_display( T : Calendar.Time:= Calendar.Clock; Seconds : Boolean := True; Intra_day: Boolean := True ) return String is use Calendar; subtype Sec_int is Long_Integer; -- must contain 86_400 s : constant Sec_int:= Sec_int( Calendar.Seconds(T) ); m : constant Sec_int:= s / 60; -- + 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); -- function Optional_seconds return String is begin if Seconds then return ':' & ssc( ssc'Last-1 .. ssc'Last ); else return ""; end if; end Optional_seconds; -- function Optional_intra_day return String is begin if Intra_day then return " " & shr( shr'Last-1 .. shr'Last ) & ':' & smn( smn'Last-1 .. smn'Last ) & Optional_seconds; else return ""; end if; end Optional_intra_day; 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 ) & Optional_intra_day; end Time_display; _________________________ Gautier's Ada programming http://gautiersblog.blogspot.com/search/label/Ada NB: follow the above link for a valid e-mail address