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 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7dadb26e573572d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-09 05:22:48 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.gbronline.com!news.gbronline.com.POSTED!not-for-mail NNTP-Posting-Date: Tue, 09 Dec 2003 07:22:47 -0600 Date: Tue, 09 Dec 2003 08:23:16 -0500 From: Wes Groleau Reply-To: groleau@freeshell.org Organization: Ain't no organization here! User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en, es-mx, pt-br, fr-ca MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: ada calendar References: <4948f537.0312060753.6b03e2ef@posting.google.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 69.9.86.13 X-Trace: sv3-60P+KZnSGxQ+XMbRV34dP9KCJngUS5vlDTyHDYzOXrLoEh8hexX75lZlKr0QQqeKIAJpFdws3ZZj0Y8!PfXzv7WqgHITbzYGOigUnryK8ivvtiK19c9xTl4KTnvgTLKBWx1kE5qOZh2xW28shvtCIVc/NgX1 X-Complaints-To: abuse@gbronline.com X-DMCA-Complaints-To: abuse@gbronline.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:3270 Date: 2003-12-09T08:23:16-05:00 List-Id: >>> You can do it with Ada.Calendar: >>> >>> Your_Function (Time_Of >>> (Year_Number'Value (S (7 .. 10)), >>> Month_Number'Value (S (4 .. 5)), >>> Day_Number'Value (S (1 .. 2)))); >>> >>> where S is your string containing "27/06/2003" or similar. >> >> There is no guarantee that S start to 1. It should be using S'First as >> offset to compute all slices. > > True, but there's an alternative technique, and possibly a better one in > this kind of case, using implicit array conversion: > > subtype Date_String is String(1..10); > X: constant Date_String := S; -- checks length and slides if necessary > ... > if X(3) /= '/' or X(6) /= '/' then raise ...; end if; Or one could use predefined string operations to split the string on '/' marks/ Or Index to find the '/' marks. These would add robustness--leading zeroes and extra spaces would be neither required nor would they mess it up. -- Wes Groleau "To know what you prefer, instead of humbly saying Amen to what the world tells you you should prefer, is to have kept your soul alive." -- Robert Louis Stevenson