From: erlo.haugen@gmail.com
Cc: mailbox@dmitry-kazakov.de
Subject: Re: Ada.Calendar and NTP (and Unix Epoch)
Date: Tue, 24 Jul 2012 05:27:30 -0700 (PDT)
Date: 2012-07-24T05:27:30-07:00 [thread overview]
Message-ID: <221dd619-09dd-4d62-9a42-f967471c3d12@googlegroups.com> (raw)
In-Reply-To: <i40m7m2dvxtu.pxub1yo0ucwt$.dlg@40tude.net>
> 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
next prev parent reply other threads:[~2012-07-26 14:40 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-23 21:42 Ada.Calendar and NTP (and Unix Epoch) erlo
2012-07-23 22:07 ` Adam Beneschan
[not found] ` <5s8s08lv6dj1i4tkb99roq9roifsgr44vd@invalid.netcom.com>
2012-07-24 7:11 ` Dmitry A. Kazakov
2012-07-24 7:50 ` erlo.haugen
2012-07-24 8:14 ` Dmitry A. Kazakov
2012-07-24 8:34 ` erlo.haugen
2012-07-24 9:13 ` Dmitry A. Kazakov
2012-07-24 12:27 ` erlo.haugen [this message]
2012-07-24 13:02 ` Dmitry A. Kazakov
2012-07-24 14:10 ` erlo
2012-07-24 16:37 ` Adam Beneschan
2012-07-24 7:24 ` erlo.haugen
2012-07-24 16:26 ` Adam Beneschan
2012-07-24 18:28 ` Dmitry A. Kazakov
2012-07-24 19:07 ` Adam Beneschan
2012-07-24 20:17 ` Dmitry A. Kazakov
2012-07-24 19:43 ` Vasiliy Molostov
2012-07-24 20:29 ` Dmitry A. Kazakov
2012-07-24 21:22 ` Vasiliy Molostov
2012-07-25 6:32 ` Dmitry A. Kazakov
2012-07-25 7:04 ` Vasiliy Molostov
2012-07-25 7:33 ` Dmitry A. Kazakov
2012-07-25 8:05 ` Vasiliy Molostov
2012-07-25 8:30 ` Dmitry A. Kazakov
2012-07-25 8:45 ` Vasiliy Molostov
2012-07-25 9:30 ` Dmitry A. Kazakov
2012-07-24 20:33 ` Simon Wright
2012-07-25 10:14 ` Simon Wright
2012-07-25 13:16 ` Dmitry A. Kazakov
2012-07-24 7:37 ` erlo.haugen
2012-07-24 11:34 ` Simon Wright
2012-07-24 11:59 ` Nasser M. Abbasi
2012-07-24 15:08 ` Simon Wright
2012-07-24 16:59 ` Georg Bauhaus
2012-07-24 19:25 ` Simon Wright
2012-07-24 22:07 ` Georg Bauhaus
2012-07-24 19:17 ` John B. Matthews
2012-07-25 2:23 ` sla29970
2012-07-25 6:40 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox