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.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_24_48 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.224.138.146 with SMTP id a18mr1465854qau.6.1343316825727; Thu, 26 Jul 2012 08:33:45 -0700 (PDT) Received: by 10.66.85.162 with SMTP id i2mr1809373paz.30.1343316394641; Thu, 26 Jul 2012 08:26:34 -0700 (PDT) Path: a15ni113198934qag.0!nntp.google.com!q21no6764897qas.0!news-out.google.com!b9ni65091145pbl.0!nntp.google.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newspump.sol.net!xlned.com!feeder5.xlned.com!feed.xsnews.nl!border-1.ams.xsnews.nl!newsfeed.straub-nv.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Ada.Calendar and NTP (and Unix Epoch) Date: Tue, 24 Jul 2012 21:33:34 +0100 Organization: A noiseless patient Spider Message-ID: References: <500dc548$0$2936$f40e02c5@shockwave.dk.telia.net> <18893cca-baa2-4930-bfb4-4c4f7eb7e983@googlegroups.com> <60c9c92b-280b-4178-a410-2bc8756c6b5e@googlegroups.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="edf2659fbb8cb6d4b5f62db4b36ac1e6"; logging-data="20298"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18K6O61oSPO1jHcHObmphESlA8oXeGQycY=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (darwin) Cancel-Lock: sha1:+LhR9shRt1jLH1U/mxfq4YVxZXI= sha1:MRjLA8I5R3ECAV95HVcheK0QZRs= Content-Type: text/plain Date: 2012-07-24T21:33:34+01:00 List-Id: erlo.haugen@gmail.com writes: >> 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 that time period. So I'm not really >> sure what the issue is. I think you need to be more specific about >> what you're trying to do. What kind of value is your program >> using for an "NTP time"--is it an integer, and if so, what >> does it represent (seconds since 1-1-1900, nanoseconds since >> 1-1-1900, or what)? Are you trying to see if an NTP time is less >> than or greater than a value of Ada.Calendar.Time, or compute the >> difference in seconds (or something else) between an NTP time value >> and an Ada.Calendar.Time value, or what? >> >> -- Adam > NTP epoch 1 started 1-1-1900 0:00, just like the Unix epoch started > 1-1-1970 0:00. So when I get a time from an NTP-server, I get seconds > from the start of the NTP epoch. Yes; but if you regard the 64-bit value as a *signed* value then the current NTP value is about -24 years. The next NTP epoch is in 2036, which is easily representable in Ada.Calendar.Time. So, *add* -24 to 2036 and, presto, 2012! In UTC. Of course, if you are worried about leap seconds, you are in for a world of pain either way. >From Wikipedia[1], NTP delivers UTC time. UTC is subject to scheduled leap seconds to synchronize the timescale to the rotation of the earth. When a leap second is added, NTP is suspended for 1 second. Because NTP has no mechanism for remembering the history of leap seconds, leap seconds cause the entire NTP timescale to shift by 1 second. [1] http://en.wikipedia.org/wiki/Network_Time_Protocol#Leap_seconds