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.107.136.19 with SMTP id k19mr15550667iod.5.1446383760951; Sun, 01 Nov 2015 05:16:00 -0800 (PST) X-Received: by 10.182.103.138 with SMTP id fw10mr171857obb.17.1446383760899; Sun, 01 Nov 2015 05:16:00 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!i2no1399542igv.0!news-out.google.com!z4ni42801ign.0!nntp.google.com!i2no1399541igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 1 Nov 2015 05:16:00 -0800 (PST) In-Reply-To: <1nxslnaexjrzg$.1ju1zr97655bq$.dlg@40tude.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2001:7e8:d039:4f01:9dac:97d9:1ff6:6a9c; posting-account=sDyr7QoAAAA7hiaifqt-gaKY2K7OZ8RQ NNTP-Posting-Host: 2001:7e8:d039:4f01:9dac:97d9:1ff6:6a9c References: <1nxslnaexjrzg$.1ju1zr97655bq$.dlg@40tude.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <419e7043-0d61-4e20-a1d0-627d609ce42f@googlegroups.com> Subject: Re: A few questions From: Laurent Injection-Date: Sun, 01 Nov 2015 13:16:00 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:28157 Date: 2015-11-01T05:16:00-08:00 List-Id: On Saturday, 31 October 2015 21:49:24 UTC+1, Dmitry A. Kazakov wrote: > > subtype Period is range Begin_Date .. End_Date; > > 1. How is this subtype would be different from Date? > Perhaps in some declarative language where lists are an fundamental part of the language itself the compiler could be smart enough to make Period a list and fill it with dates from..to? Yeah I know mind-reading compiler and World of Fantasycraft :) > 2. Date is not a numeric type to have ranges Agreed > 3. Date cannot be a numeric type because arithmetic operations would not > make sense: D1 + D2 is what? Nonsense :) > > I naively thought that it could be so easy. > > Yes, because it is wrong. What? Being naive or thinking that it could/should be easy? :) > > 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. I actually mentioned the "-" only because it would spare me from having to roll my own to figure out how many days are between D1 and D2. But I think that it is probably not necessary at all. > > 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. I think getting the names done is the easiest part. When first took a look at the log files I thought that it would be difficult to extract the informations I am looking for. But no getting some continuous dates from .. to is the real PITA. Otherwise it would be boring. Thanks