comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Newbie Q: How to program in UTC (time/calendar) ?
Date: Tue, 24 Mar 2009 10:18:07 +0100
Date: 2009-03-24T10:18:07+01:00	[thread overview]
Message-ID: <1hxxcfzcbidwy$.c3pd16bnvraz$.dlg@40tude.net> (raw)
In-Reply-To: 89277c47-788d-441c-95b2-f47e1b70a532@j39g2000yqn.googlegroups.com

On Tue, 24 Mar 2009 01:51:57 -0700 (PDT), reinkor wrote:

> What is the "natural"/best way to make an Ada program
> treat time/calendar data in UTC ?  The quetion is about
> treating old measurements/data tagged with UTC time.
> 
> I use
> 
> � Offset : Constant Time_Offset := UTC_Time_Offset;
> 
> and include "Time_Zone=>Offset" in calendar routines
> (for example in the functions Time_Of, Split, Value
> within �the packages Ada.Calendar.Formatting and
> Ada.Calendar.Time_Zones).
> 
> I find this a but "artificial". How should one do it?

Sorry for bringing you bad news, but unfortunately there is no way to
handle UTC in Ada. The standard is broken in this respect. I discussed this
in this group earlier and in Ada-Comment too.

The short answer is that if you wanted to deal with UTC, you should have a
look at the implementation of Ada.Calendar.Time provided by your compiler
and then act accordingly.

A longer answer is that UTC_Time_Offset is not necessarily constant. Thus
your way is possibly wrong. Here we come to the inconsistency of the
standard. How does UTC_Time_Offset depend on Time in its turn depends on
what is *Time*. Your solution presumes that Time is UTC (i.e. UTC +
constant offset). This might be wrong, because the standard gives strong
indications that Time is in fact local time = political time. In this case
the offset would depend on the current UTC, and could not depend on Time as
the function UTC_Time_Offset pretends. Offset is not a function of
political time (it is not a function at all). In short, it is broken.

I cannot tell for sure, but it seems that GNAT implementation is Time =
UTC. I.e. Clock does not jump when daylight saving time comes and thus
Split may yield rubbish...

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



  reply	other threads:[~2009-03-24  9:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-24  8:51 Newbie Q: How to program in UTC (time/calendar) ? reinkor
2009-03-24  9:18 ` Dmitry A. Kazakov [this message]
2009-03-24 10:07 ` Martin
2009-03-24 10:55   ` reinkor
2009-03-24 12:49     ` Martin
2009-03-24 18:53       ` Dirk Heinrichs
2009-03-24 23:59         ` Martin
2009-03-25 10:21           ` reinkor
2009-03-25 15:28             ` tmoran
2009-03-25 21:55               ` sjw
2009-03-26  1:38                 ` tmoran
2009-03-26 20:58                   ` sjw
2009-03-27 12:52                     ` reinkor
2009-03-27 16:58                       ` Jeffrey R. Carter
2009-03-30 11:27                         ` reinkor
2009-03-30 16:47                           ` Jeffrey R. Carter
2009-03-30 12:37                         ` reinkor
2009-03-30 13:45                           ` John B. Matthews
2009-03-30 16:52                           ` Jeffrey R. Carter
2009-03-30 19:34                             ` reinkor
2009-03-30 19:44                             ` reinkor
2009-04-04  2:22                     ` Brian Gaffney
2009-03-24 11:29 ` Jacob Sparre Andersen
replies disabled

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