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 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 From: Brian May Newsgroups: comp.lang.ada Subject: Re: ADA.CALENDAR and midnight References: Date: Thu, 05 Aug 2004 21:46:03 +1000 Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:vqCglbBY7Ll/2J1NAxlROLygxiQ= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: dsl-202-173-153-89.vic.westnet.com.au X-Trace: news.melbourne.pipenetworks.com 1091706363 202.173.153.89 (5 Aug 2004 21:46:03 +1000) X-Complaints-To: abuse@pipenetworks.com X-Abuse-Info: Please forward all headers to enable your complaint to be properly processed. Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!news.mel.connect.com.au!news.melbourne.pipenetworks.com!not-for-mail Xref: g2news1.google.com comp.lang.ada:2573 Date: 2004-08-05T21:46:03+10:00 List-Id: >>>>> "Nick" == Nick Roberts writes: Nick> If Time_Of is called with a seconds value of 86_400.0, the value Nick> returned is equal to the value of Time_Of for the next day with a Nick> seconds value of 0.0. The value returned by the function Seconds or Nick> through the Seconds parameter of the procedure Split is always less Nick> than 86_400.0. Nick> So I would say that an implementation which returns 86_400.0 is Nick> faulty. Hmmm.. Have to double check. I have the following function (spot the bug!), for displaying times in hh:mm:ss format. >-------function To_String(The_Time : in Time) return String is >------->-------Duration : Integer; >------->-------H : Integer range 1..24; >------->-------M : Integer range 0..60; >------->-------S : Integer range 0..60; >-------begin >------->-------Duration := Integer(Seconds(The_Time)); >------->-------S := Duration mod 60; >------->-------Duration := (Duration-S)/60; >------->-------M := Duration mod 60; >------->-------Duration := (Duration-M)/60; >------->-------H := Duration; >------->------- >------->-------return Strip(Integer'Image(H))&":" >------->------->-------&Strip(Integer'Image(M))&":" >------->------->-------&Strip(Integer'Image(S)); >-------end To_String; The first call is To_String(Clock + offset). When an exception occurs, it is called as To_String(Clock) for the log message. Strip is just a function that strips off leading white space. This worked until around midnight. Predictably, I got a constraint exception when assigning the value to H, because my limits are wrong. However, when printing the exception message, this function is called again[1], and returned the result of "24:0:0". I am kind of confused this is possible, unless Duration was initially 86_400.0[2]. Maybe somewhere my logic is flawed, I will investigate again tomorrow. Notes: [1] hmmm... what happens if you get a recursive exception in Ada? I probably should protect my logging functions a bit better. [2] Can someone confirm my assumption that Integer(86_399.9) = 86_399? -- Brian May