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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: A few questions Date: Sat, 31 Oct 2015 21:49:13 +0100 Organization: cbb software GmbH Message-ID: <1nxslnaexjrzg$.1ju1zr97655bq$.dlg@40tude.net> References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: j6IQVb9uobzjXrpQLDU2rQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:28153 Date: 2015-10-31T21:49:13+01:00 List-Id: On Sat, 31 Oct 2015 13:29:51 -0700 (PDT), Laurent wrote: > I need a range of Dates. > > So I tried this: > > Begin_Date: Dates.Object; > End_Date: Dates.Object; > -- Dates is a package from an earlier example in my Ada95 book. It is based on Ada.Calendars. I prefer to use > -- Dates because I actually need only the date, I don't care/ need the hour. I also find the name "Time" for > -- something like "2015/10/31 21:00:00" confusing but that's just my opinion. > > That doesn't work unfortunately and the compiler is right to complain: > > subtype Period is range Begin_Date .. End_Date; 1. How is this subtype would be different from Date? 2. Date is not a numeric type to have ranges 3. Date cannot be a numeric type because arithmetic operations would not make sense: D1 + D2 is what? > I naively thought that it could be so easy. Yes, because it is wrong. > I have found in Ada.Calendar a: function "-" (L,R:Time) return Duration Similarly D1 - D2 is a Duration, not a date. Likewise you can add duration to a date, but not a date to date. > Is it possible to make a casting to convert my Date type in (Ada.Calendar) Time type: > > Today : Ada.Calendar.Time:= Time(Date); -- or something like that. No problem. You would have an equivalent of Year, Month, Day functions defined for Date. Then you would call Time_Of. That is. > So is there an existing package which generates a range of Dates from .. to? No, but you could have an abstract iterator for dates in Ada 2012. > PS: need this range of dates because the log files I want to read and > extract informations from are all named like this: vba-yyyymmdd.log where > obviously yyyymmdd is the date. The program generates a new file every > date an stores the communication it treated in it. See Ada.Calendar.Formatting.Image. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de