comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Inserting Calendar.Time in a database
Date: Thu, 26 Aug 2004 13:55:43 -0500
Date: 2004-08-26T13:55:43-05:00	[thread overview]
Message-ID: <eIWdnYG0o_FlrLPcRVn-qQ@megapath.net> (raw)
In-Reply-To: 19pc26q7dwvt2.1fyyqhr5nv5j2$.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:19pc26q7dwvt2.1fyyqhr5nv5j2$.dlg@40tude.net...
...
> > The point is that you must never save values of UTC_Adjustment, but
rather
> > recalculate them each time. Hopefully the implementation of
> > Ada.Calendar.Time_Zones doesn't make this too expensive.
>
> So UTC_Time_Offset should remember the local zone time adjusting history
> and also foresee all future adjustments? How efficient it would be?

It's just a system call of some sort, its certainly no worse than calling
Clock itself and probably is much better.

> Say, there are 32 1kHz channels, for each value I need a time stamp. A
real-life
> application should convert Ada...Clock to FILETIME. It would using Split +
> the formula for leap years, seconds etc, all that in an interrupt handler?

The overhead of calling Clock is such that it would not make sense to do
this on many existing implementations, even if you use Ada.Real_Time. It
certainly would make no sense on any system built on top of Windows or Unix
or Linux. The adjustment to the local time isn't a big enough portion of
that overhead to matter much.

I would expect that it might be possible on some real-time kernels. For
those, it's clear that Ada.Calendar.Time should be UTC time, and a child
package provided to get the Local_Time_Offset if that is needed. (That
really ought to be required behavior of Calendar, but it's simply too
incompatible - and in the worst way, at run time - to do.)

An alternative (especially in the inprecise requirements that you suggested
in your message) is to figure the time base of Ada.Real_Time, then using
Real_Time for most operations. Indeed, this is exactly how Calendar is
implemented on Janus/Ada and on GNAT for Windows: the system time functions
are used to get the time base, and QueryPerformanceCounter is used to get
high precision time information within that time base. (Of course, the fact
that QueryPerformanceCounter leaps forward many seconds on some hardware is
a problem.) We rebase every 5 minutes to avoid drift problems from using two
separate clocks; I believe GNAT is similar.

In any case, the sorts of requirements that you have are simply not
supportable within the standard. (Or implementations, for that matter.) No
Ada vendor is going to guarantee anything about the accuracy of the time
base (because it's completely out of their control), which is a necessary
parameter in any sort of distributed system. Either it doesn't matter much
(as in HTTP), or you are going to have to take steps to insure that it is
accurate enough, and that requires going beyond anything that the standard
could possibly give you.

                       Randy.







  parent reply	other threads:[~2004-08-26 18:55 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-05 13:44 Inserting Calendar.Time in a database Jano
2004-08-05 15:21 ` Dmitry A. Kazakov
2004-08-05 21:19   ` Martin Dowie
2004-08-06  6:31     ` Jano
2004-08-06 11:32       ` Peter Hermann
2004-08-06 11:40         ` Duncan Sands
2004-08-08 11:10           ` Jano
2004-08-06  7:48     ` Dmitry A. Kazakov
2004-08-06  9:28       ` Martin Dowie
2004-08-06 10:44         ` Dmitry A. Kazakov
2004-08-07  9:50           ` Martin Dowie
2004-08-07 20:32             ` Dmitry A. Kazakov
2004-08-08  8:35               ` Martin Dowie
2004-08-08 11:03                 ` Simon Wright
2004-08-09  7:46                 ` Dmitry A. Kazakov
2004-08-09 17:54                   ` Nick Roberts
2004-08-10  7:33                     ` Dmitry A. Kazakov
2004-08-10  8:36                     ` John B. Matthews
2004-08-10 18:51                       ` Nick Roberts
2004-08-11  1:14                         ` John B. Matthews
2004-08-19  4:10                         ` Jano
2004-08-19  4:10                       ` Jano
2004-08-09 11:52                 ` Frank J. Lhota
2004-08-08 10:46       ` Simon Wright
2004-08-09  8:02         ` Dmitry A. Kazakov
2004-08-24 19:25       ` Randy Brukardt
2004-08-25  7:24         ` Dmitry A. Kazakov
2004-08-25  8:18           ` Martin Dowie
2004-08-25  9:25             ` Dmitry A. Kazakov
2004-08-25  9:42               ` Martin Dowie
2004-08-26  5:26               ` Simon Wright
2004-08-26  0:49           ` Randy Brukardt
2004-08-26  9:30             ` Dmitry A. Kazakov
2004-08-26 10:11               ` Martin Dowie
2004-08-26 10:58                 ` Dmitry A. Kazakov
2004-08-26 12:32                   ` Martin Dowie
2004-08-26 16:26                     ` Dmitry A. Kazakov
2004-08-26 17:23                       ` Martin Dowie
2004-08-26 18:55               ` Randy Brukardt [this message]
2004-08-26 20:04                 ` Dmitry A. Kazakov
2004-08-26  5:22           ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox