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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bba7760fccef922d,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-03 06:26:39 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!203.50.2.79!intgwlon.nntp.telstra.net!nsw.nnrp.telstra.net!not-for-mail Message-ID: <3B428DB5.89E1D528@mullum.com.au> From: Charles Darcy X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.3-20mdk i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Ada.Calendar."+" gives peculiar result (Gnat 3.13) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 03 Jul 2001 23:29:57 -0400 NNTP-Posting-Host: 203.109.169.35 X-Complaints-To: abuse@telstra.net X-Trace: nsw.nnrp.telstra.net 994166789 203.109.169.35 (Tue, 03 Jul 2001 23:26:29 EST) NNTP-Posting-Date: Tue, 03 Jul 2001 23:26:29 EST Organization: Customer of Telstra Big Pond Direct Xref: archiver1.google.com comp.lang.ada:9368 Date: 2001-07-03T23:29:57-04:00 List-Id: Hello, I've been using the Ada.Calendar.Time type to represent dates in my program, and have struck a problem. Within a loop, I add (7 * Ada.Calendar.Day_Duration'Last) to an Ada.Calendar.Time object, at the end of each iteration. I expected this to advance the time by 1 week, and so it does initially. After a number of loop iterations, however, the addition seems to advance the time by 1 week and 1 hour. Below is code which demonstrates the problem: declare use Ada.Text_IO; use Ada.Calendar; The_Year : Year_Number; The_Month : Month_Number; The_Day : Day_Number; The_Seconds : Day_Duration; The_Date : Time := Time_Of (1995, 12, 2); begin for Count in 1 .. 100 loop Put_Line (""); Put_Line ("Iteration: " & Integer'Image (Count)); Split (The_Date, The_Year, The_Month, The_Day, The_Seconds); Put_Line ("The_Date:"); Put_Line (" year: " & Year_Number'Image (The_Year)); Put_Line (" month: " & Month_Number'Image (The_Month)); Put_Line (" day: " & Day_Number'Image (The_Day)); Put_Line (" seconds: " & Day_Duration'Image (The_Seconds)); The_Date := The_Date + 7 * Ada.Calendar.Day_Duration'Last; end loop; end; The output begins with ... Iteration: 1 The_Date: year: 1995 month: 12 day: 2 seconds: 0.000000000 Iteration: 2 The_Date: year: 1995 month: 12 day: 9 seconds: 0.000000000 Iteration: 3 The_Date: year: 1995 month: 12 day: 16 seconds: 0.000000000 ... which is as I expected. However, later on ... Iteration: 19 The_Date: year: 1996 month: 4 day: 6 seconds: 0.000000000 Iteration: 20 The_Date: year: 1996 month: 4 day: 13 seconds: 3600.000000000 Iteration: 21 The_Date: year: 1996 month: 4 day: 20 seconds: 3600.000000000 ... an additional hour (the 3600 seconds) seems to have been added. Still later, the additional hour disappears ... Iteration: 48 The_Date: year: 1996 month: 10 day: 26 seconds: 3600.000000000 Iteration: 49 The_Date: year: 1996 month: 11 day: 2 seconds: 0.000000000 Iteration: 50 The_Date: year: 1996 month: 11 day: 9 seconds: 0.000000000 Any ideas as to what is going on ? In case its relevant, I'm using Gnat 3.13p under Linux. regards, Charles. P.S. Can anyone recommend a good Date package ?