comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Timing Block of GNAT code in milliseconds
Date: Fri, 29 Apr 2005 15:52:55 -0500
Date: 2005-04-29T15:52:55-05:00	[thread overview]
Message-ID: <oaidnWyBSNGQA-_fRVn-jg@megapath.net> (raw)
In-Reply-To: 10m95m5yelieq$.kj1rktb792s3.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:10m95m5yelieq$.kj1rktb792s3.dlg@40tude.net...
...
> We need time stamps synchronized across the network. The accuracy of
> synchronization is the second problem. The first problem is that the very
> idea of synchronized time stamps cannot be expressed in Ada terms. There
is
> no portable way to get say UTC from either Calendar or Real_Time, or to
> convert UTC to them.

Of course there is (assuming that you have a compiler that supports the Ada
2006 Ada.Calendar.Time_Zone and Ada.Calendar.Formatting.Split packages).

declare
     Now : Ada.Calendar.Time := Ada.Calendar.Clock;
     UTC_Offset : Ada.Calendar.Time_Zones.Time_Offset :=
           Ada.Calendar.Time_Zones.UTC_Time_Offset (Now);
begin
    Ada.Calendar.Formatting.Split (Now, Time_Zone => UTC_Offset, <other
parts of the UTC time>);
    ...
end;

It's a bit clunky, but that is the price of undoing daylight savings time.
If your time period is short enough (doesn't cross any hour boundaries in
the early morning), you can just get the offset once.

And you can use Time_Of with a Time_Zone parameter to construct a value.

                          Randy.






  parent reply	other threads:[~2005-04-29 20:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-21 13:28 Timing Block of GNAT code in milliseconds markp
2005-04-21 18:00 ` tmoran
2005-04-21 18:53   ` markp
2005-04-21 19:40     ` Marc A. Criley
2005-04-21 19:44     ` Simon Wright
2005-04-22  1:00   ` Steve
2005-04-23  5:39     ` Simon Wright
2005-04-23 17:49       ` Steve
2005-04-24 18:57         ` Simon Wright
2005-04-24 20:05           ` Dmitry A. Kazakov
2005-04-25 22:56             ` Randy Brukardt
2005-04-28 20:26             ` Simon Wright
2005-04-29  8:11               ` Dmitry A. Kazakov
2005-04-29 18:25                 ` tmoran
2005-04-29 19:19                   ` Dmitry A. Kazakov
2005-04-29 20:24                     ` tmoran
2005-04-30  9:47                       ` Dmitry A. Kazakov
2005-04-29 20:52                 ` Randy Brukardt [this message]
2005-04-30 10:02                   ` 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