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-Thread: a07f3367d7,59c3b3f9911c9191 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.85.231 with SMTP id k7mr1821763paz.38.1343316971307; Thu, 26 Jul 2012 08:36:11 -0700 (PDT) Path: b9ni65157917pbl.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-peer1!btnet!zen.net.uk!hamilton.zen.co.uk!xlned.com!feeder5.xlned.com!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.straub-nv.de!news.swapon.de!news.glorb.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Ada.Calendar and NTP (and Unix Epoch) Date: Mon, 23 Jul 2012 15:07:48 -0700 (PDT) Organization: http://groups.google.com Message-ID: <18893cca-baa2-4930-bfb4-4c4f7eb7e983@googlegroups.com> References: <500dc548$0$2936$f40e02c5@shockwave.dk.telia.net> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1343081372 7420 127.0.0.1 (23 Jul 2012 22:09:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 23 Jul 2012 22:09:32 +0000 (UTC) In-Reply-To: <500dc548$0$2936$f40e02c5@shockwave.dk.telia.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Received-Bytes: 2984 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-07-23T15:07:48-07:00 List-Id: On Monday, July 23, 2012 2:42:32 PM UTC-7, erlo wrote: > The following code raises an ADA.CALENDAR.TIME_ERROR exception: >=20 > with Calendar; > with Calendar.Conversions; > with Calendar.Arithmetic; > with Calendar.Formatting; > with Text_IO; > with Ada.Exceptions; >=20 > use Calendar; > use Text_IO; >=20 >=20 > procedure Main is > AdaTid : Time; > begin > AdaTid :=3D Conversions.To_Ada_Time(tm_year =3D> 00, > tm_mon =3D> 00, > tm_day =3D> 01, > tm_hour =3D> 0, > tm_min =3D> 0, > tm_sec =3D> 0, > tm_isdst =3D> 0); -- raises excepti= on >=20 >=20 > put_line(Formatting.Image(Date =3D> AdaTid, > Include_Time_Fraction =3D> False, > Time_Zone =3D> 0)); >=20 > end Main; >=20 > This is because Ada.Calendar starts at 1-1-1901. But NTP starts at=20 > 1-1-1900, so how can I work my way around this issue? My gut feeling is that if NTP gives you a time in the range 1-1-1900 to 12-= 31-1900, something is pretty wrong because computers didn't exist during th= at time period. So I'm not really sure what the issue is. I think you nee= d to be more specific about what you're trying to do. What kind of value i= s your program using for an "NTP time"--is it an integer, and if so, what d= oes it represent (seconds since 1-1-1900, nanoseconds since 1-1-1900, or wh= at)? Are you trying to see if an NTP time is less than or greater than a v= alue of Ada.Calendar.Time, or compute the difference in seconds (or somethi= ng else) between an NTP time value and an Ada.Calendar.Time value, or what?= =20 -- Adam