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,7dadb26e573572d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-05 16:11:36 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!82-43-33-75.cable.ubr01.croy.blueyonder.co.UK!not-for-mail From: Nick Roberts Newsgroups: comp.lang.ada Subject: Re: ada calendar Date: Sat, 06 Dec 2003 00:11:26 +0000 Message-ID: References: <4948f537.0312051300.d246254@posting.google.com> NNTP-Posting-Host: 82-43-33-75.cable.ubr01.croy.blueyonder.co.uk (82.43.33.75) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1070669494 74064940 82.43.33.75 ([25716]) User-Agent: Mozilla/5.0 (Windows; U; Win95; en-GB; rv:1.5) Gecko/20031007 X-Accept-Language: en-gb, en, en-us In-Reply-To: Xref: archiver1.google.com comp.lang.ada:3169 Date: 2003-12-06T00:11:26+00:00 List-Id: Stephen Leake wrote: >>how can i add one week to clendar.time record using duration ? > > with Ada.Calendar; use Ada.Calendar; > procedure One_Week > is > One_Minute : constant Duration := 60.0; > One_Hour : constant Duration := 60 * One_Minute; > One_Day : constant Duration := 24 * One_Hour; > One_Week : constant Duration := 7 * One_Day; > > Now : Time := Clock; > begin > Now := Now + One_Week; > end One_Week; This may work on some implementations. If it fails, the compiler should issue a fatal error. In this case, Tom Moran's suggestion: One_Minute : constant Duration := 60.0; One_Hour : constant Duration := 60 * One_Minute; One_Day : constant Duration := 24 * One_Hour; Now : Time := Clock; begin for Day in 1 .. 7 loop Now := Now + One_Day; end loop; ought to work. There is a proposal to add this functionality in the next revision of the language (AI-351). -- Nick Roberts