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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no 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.236.170.1 with SMTP id o1mr15280585yhl.42.1343313657364; Thu, 26 Jul 2012 07:40:57 -0700 (PDT) Received: by 10.66.77.199 with SMTP id u7mr1625639paw.25.1343313567361; Thu, 26 Jul 2012 07:39:27 -0700 (PDT) Path: a15ni113198934qag.0!nntp.google.com!q21no1190878qas.0!news-out.google.com!p10ni64816900pbh.1!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!border6.newsrouter.astraweb.com!news.astraweb.com!border6.a.newsrouter.astraweb.com!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.straub-nv.de!news-1.dfn.de!news-2.dfn.de!news.dfn.de!feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!82.197.223.103.MISMATCH!feeder3.cambriumusenet.nl!feed.tweaknews.nl!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: erlo.haugen@gmail.com Newsgroups: comp.lang.ada Subject: Re: Ada.Calendar and NTP (and Unix Epoch) Date: Tue, 24 Jul 2012 05:27:30 -0700 (PDT) Organization: http://groups.google.com Message-ID: <221dd619-09dd-4d62-9a42-f967471c3d12@googlegroups.com> References: <500dc548$0$2936$f40e02c5@shockwave.dk.telia.net> <18893cca-baa2-4930-bfb4-4c4f7eb7e983@googlegroups.com> <5s8s08lv6dj1i4tkb99roq9roifsgr44vd@invalid.netcom.com> <1e0fmpgo1d8ke.7gc1rzrv8v72.dlg@40tude.net> <6f28df4c-6b1a-46d1-a3b9-9ae41ea975a2@googlegroups.com> <4l5t6lhzgquo$.qa4ud3ssphtd.dlg@40tude.net> <4b3daad0-b884-4f42-9aa5-891bcfeadf87@googlegroups.com> NNTP-Posting-Host: 193.163.1.105 Mime-Version: 1.0 X-Trace: posting.google.com 1343132949 10277 127.0.0.1 (24 Jul 2012 12:29:09 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 24 Jul 2012 12:29:09 +0000 (UTC) Cc: mailbox@dmitry-kazakov.de In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=193.163.1.105; posting-account=N7skygoAAAA1XsML8HGZssZ0aoLQa6Br User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-07-24T05:27:30-07:00 List-Id: > Where is a problem then? > > E1 + T1 vs. E2 + T2 > > <=> > > T1 vs. (E2 - E1) + T2 > > Where E2 - E1 is the time offset between the epochs. That's true, the issue here is that I was fooled by Ada.Calendar.Conversion spec into thinking that I can use To_Ada_Time to convert the NTP epoch base (1-1-1900 0:00) to a variable of type Time. This would make it easy to calculate the offset between the two epochs: epoch_diff := To_Ada_Time(70, 0, 1, 0, 0 ,0 0) - To_Ada_Time(00, 0, 1, 0, 0 ,0 0) Snip from Ada.Calendar.Conversion spec: function To_Ada_Time (tm_year : Interfaces.C.int; tm_mon : Interfaces.C.int; tm_day : Interfaces.C.int; tm_hour : Interfaces.C.int; tm_min : Interfaces.C.int; tm_sec : Interfaces.C.int; tm_isdst : Interfaces.C.int) return Time; -- Convert a time value expressed in Unix-like fields of struct tm into -- a Time value relative to the Ada Epoch. The ranges of the formals are -- as follows: -- tm_year -- years since 1900 *this one fooled me* -- tm_mon -- months since January [0 .. 11] I had the idea that zero would be a legal value for tm_year... > > This presumes that they represent *same* time though maybe using different > epochs. You might need to read the UNIX and NTP documentation to learn what > exactly times they do represent. That would give you E2 - E1. To put it > simple: same time = synchronized clocks. > This is the exact case. > Note that if any of two times is political, E2 - E1 does not exist as it > becomes a function of time. This where all starts really complicated and is > the reason why one should never ever mess up with the political time for > the purpose of time stamping. And this is just a relatively simple case > when clocks are synchronized but one of them is periodically skewed. > > When clocks are not synchronized, time stamps are fundamentally > incomparable without the history of synchronization, which, well, means > that they were rather synchronized. (:-)) > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de Erlo