comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada.Calendar.Time_Zones
Date: Sat, 9 Aug 2008 10:04:45 +0200
Date: 2008-08-09T10:04:46+02:00	[thread overview]
Message-ID: <18iqoye18iuzu$.jz3bz3dssmhe.dlg@40tude.net> (raw)
In-Reply-To: g7ivp3$kpa$1@jacob-sparre.dk

On Fri, 8 Aug 2008 21:09:42 -0500, Randy Brukardt wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
> news:aht87sie2uac$.ke09vcui32dj.dlg@40tude.net...
>> On Thu, 7 Aug 2008 17:47:41 -0500, Randy Brukardt wrote:
>>
>>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
>>> news:61migfnkb0sm.8wytouvj8o4f.dlg@40tude.net...
>>> ...
>>>> But all that stuff like Time_Of etc is not really needed with UTC_Time.
>>>> The package should provide Clock, +, -, <, <=, >, >=:
>>>
>>> I don't see how that could work. How would you display or create a UTC 
>>> time?
>>
>> No problem:
>>
>>   T : Ada.UTC_Time.Time := ...;
>>   P : Ada.Calendar.Time := To_Calendar_Time (T);
>>
>> P is the political time corresponding to T, it is well-defined for each T.
>> P can be used in Ada.Calendar.Split to display T as:
>>
>>   August 08, 2008 10:18 (Berlin time)
>>
>> When used in Ada.Calendar.Formatting.Split with
>>
>>   Time_Zone => UTC_Time_Offset (T)
>>
>> the display could be:
>>
>>   August 08, 2008 09:18 (UTC time)
> 
> Sorry, this doesn't make any sense. Your original point, boiled down, is 
> that it is never safe to convert from political time to UTC (because of the 
> overlaps and holes). But then you go ahead and do exactly that.

It is safe in this case because it uses an external zone offset. The
conversion is unsafe when an attempt is made to determine the offset from
the political time itself. That is inconsistent. But when the offset is
determined by the UTC time, then everything is fine.

> In any case, if you were willing to require that, the current specification 
> would work just fine for UTC time (because you could always get the UTC time 
> directly from the record). In which case there is no problem, so we don't 
> need an additional mechanism.

Yes, this is what GNAT does, at least under Windows.

My proposal would allow to have Ada.Calendar.Time really skewed as
politicians always whished (:-)). E.g.

   T : Time := Time_Of (2008, 10, 28, 1.5*3600.0);  -- 1h before the skew

then

   T1 := T + 1.0*3600.0;   -- 28.10.2008 02:30 before skew
   T2 := T + 2.0*3600.0;   -- 28.10.2008 02:30 after skew

   T1 = T2  -- Political arithmetic!

A time defined this way will still be convertible forth and back to UTC
time, if you know the time offset. That is 1h for T1 and 2h for T2.

-----------
But in any case, RM should clarify what it means under political time. I.e.
whether T1 = T2 (= truly political time), or not (= hidden UTC time).

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2008-08-09  8:04 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       ` Ada.Calendar.Time_Zones Dmitry A. Kazakov
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               ` Dmitry A. Kazakov [this message]
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