From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada.Calendar.Time_Zones
Date: Thu, 7 Aug 2008 10:27:35 +0200
Date: 2008-08-07T10:27:35+02:00 [thread overview]
Message-ID: <61migfnkb0sm.8wytouvj8o4f.dlg@40tude.net> (raw)
In-Reply-To: g7do2f$q8l$1@jacob-sparre.dk
On Wed, 6 Aug 2008 21:52:53 -0500, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:3jxnfgd6m2ff.ca8crnn387m3.dlg@40tude.net...
>> On Mon, 4 Aug 2008 17:12:38 -0500, Randy Brukardt wrote:
>>
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
>>> news:1rm26vi0mz4sv.1kfhdnswhcrqa.dlg@40tude.net...
>>>> Does anybody know the meaning of the result returned by UTC_Time_Offset?
>>>
>>> It's as the RM says.
>>
>> But how to translate what it says into concrete numbers:
>>
>> UTC_Time_Offset (Ada.Calendar.Time_Of (2008, 26, 10, 2.5*60.0*60.0)); =?
>>
>> OK, I am posting that to Ada comments as you suggested.
>
> I don't think the RM answers your question, which technically means that it
> is unspecified.
Which perplexes me much. How could it happen that an Ada library function
has undefined behavior.
> It is reasonable to ask if it *ought* to be unspecified,
> which is why I asked you to ask the ARG.
Yes, I did.
>>> It's pretty obvious, though, that there is no way to do this correctly
>>> unless the time type is based on UTC (time-zone-less) time. And because
>>> of
>>> compatibility concerns, the only way to do that is to completely junk
>>> Ada.Calendar and start over, duplicating essentially everything. You're
>>> probably right that we should have done that, but it would always be a
>>> tough
>>> sell (lots of people would say that Ada.Calendar is "good enough") --
>>> which
>>> is why you need to ask this question directly to the ARG. (And get as
>>> many
>>> people as possible to support it, too.) I alone could never produce
>>> critical
>>> mass on this topic.
>>
>> I don't understand this. Ada.Calendar.Time_Zones, Ada.Calendar.Arithmetic,
>> Ada.Calendar.Formatting are all new packages. All of them have an
>> inconsistent semantics, because Time_Of is necessarily inconsistent [*].
>> Zone offset is simply not a function of the local time. It is of the UTC
>> time.
>
> You'd have to completely duplicate the contents of Ada.Calendar using a new,
> very similar time type that is based on UTC.
Hmm, is Ada.Calendar big? Anyway one didn't hesitate to duplicate most of
it in Ada.Calendar.Arithmetic.
But all that stuff like Time_Of etc is not really needed with UTC_Time. The
package should provide Clock, +, -, <, <=, >, >=:
package Ada.UTC_Time is
type UTC_Time is private;
function Clock return UTC_Time;
function "+" (Left : UTC_Time; Right : Duration) return UTC_Time;
function "+" (Left : Duration; Right : UTC_Time) return UTC_Time;
function "-" (Left : UTC_Time; Right : Duration) return UTC_Time;
function "-" (Left : UTC_Time; UTC_Time : Time) return Duration;
function "<" (Left, Right : UTC_Time) return Boolean;
function "<="(Left, Right : UTC_Time) return Boolean;
function ">" (Left, Right : UTC_Time) return Boolean;
function ">="(Left, Right : UTC_Time) return Boolean;
end Ada.UTC_Time;
That's it.
Then:
package Ada.UTC_Time.Time_Zones is
type Time_Offset is range -28*60 .. 28*60;
-- This is well-defined
function UTC_Time_Offset (Date : UTC_Time := Clock) return Time_Offset;
function To_Calendar_Time (Time : UTC_Time; Time_Zone) return Time;
function To_Calendar_Time (Time : UTC_Time; Time_Zone; Time_Offset)
return Time;
-- Time Zone is always required for the backward conversion
function To_UTC_Time (Time : Time; Time_Zone; Time_Offset)
return Time;
end Ada.UTC_Time.Time_Zones;
I would also like to see conversions between Ada.Real_Time.Time and
UTC_Time.
> The real question is whether the hole is important enough to try to fix
> (given that the fix is going require adding a lot more mechanism). That's a
> question I can't answer.
Our problem is that we need to exchange time-stamped data with the outside
world. So we have to convert UTC forth and back to Ada.Real_Time.Time. It
is to expect that the system might become out of service for when the clock
is adjusted. Considering similar cases, like air flight traffic control
systems dealing with GPS clock etc, I wonder how they would handle that.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2008-08-07 8:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-04 9:31 Ada.Calendar.Time_Zones Dmitry A. Kazakov
2008-08-04 13:56 ` Ada.Calendar.Time_Zones google1
2008-08-04 14:57 ` Ada.Calendar.Time_Zones Dmitry A. Kazakov
2008-08-04 20:56 ` Ada.Calendar.Time_Zones Maciej Sobczak
2008-08-04 22:12 ` Ada.Calendar.Time_Zones Randy Brukardt
2008-08-05 9:10 ` Ada.Calendar.Time_Zones Dmitry A. Kazakov
2008-08-07 2:52 ` Ada.Calendar.Time_Zones Randy Brukardt
2008-08-07 8:27 ` Dmitry A. Kazakov [this message]
2008-08-07 22:47 ` Ada.Calendar.Time_Zones Randy Brukardt
2008-08-08 8:48 ` Ada.Calendar.Time_Zones Dmitry A. Kazakov
2008-08-09 2:09 ` Ada.Calendar.Time_Zones Randy Brukardt
2008-08-09 8:04 ` Ada.Calendar.Time_Zones Dmitry A. Kazakov
2008-08-14 0:20 ` Ada.Calendar.Time_Zones Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox