comp.lang.ada
 help / color / mirror / Atom feed
From: reinkor <reinkor@gmail.com>
Subject: Re: Newbie Q: How to program in UTC (time/calendar) ?
Date: Mon, 30 Mar 2009 12:44:05 -0700 (PDT)
Date: 2009-03-30T12:44:05-07:00	[thread overview]
Message-ID: <23cd155b-b8e8-4f53-b411-10eb2ce67a3f@v19g2000yqn.googlegroups.com> (raw)
In-Reply-To: eN6Al.38248$DP1.27599@attbi_s22

Thanks to all. Now I think I got it !

And giving the argument "Time1" to UTC_Time_Offset" like this:

 UTC_Time_Offset(Time1)

insted of only UTC_Time_Offset (which is the same
as "UTC_Time_Offset(Clock))", then I get consistency:

Time1: 1970-01-01 00:00:00
Time2: 1969-12-31 23:00:00
UTC_Time_Offset:       60

Lesson learned: "remember the argument for UTC_Time_Offset" !   :-)

reinert

PS, new program code:
-----------------------------------------------------------------------------
with Text_IO;
use  Text_IO;

with Ada.Calendar.Formatting,Ada.Calendar.Time_Zones;
-- with Ada.Calendar.Aritmetric;
use  Ada.Calendar,Ada.Calendar.Formatting,Ada.Calendar.Time_Zones;

procedure t1 is

   package Int_Io  is new Text_IO.Integer_Io (Integer);
   use Int_Io;

   Time1,Time2 : Time;

begin

   Time1 := Value("1970-01-01 00:00:00");
   Time2 := Ada.Calendar.Time_Of(1970,1,1,0.0);

   Put("Time1: ");Put(Image(Time1));New_Line;
   Put("Time2: ");Put(Image(Time2));New_Line;

   Put("UTC_Time_Offset: ");Put(Integer(UTC_Time_Offset(Time1)),8);

end t1;





On 30 Mar, 18:52, "Jeffrey R. Carter"
<spam.jrcarter....@nospam.acm.org> wrote:
> reinkor wrote:
> >    Time1 := Value("1970-01-01 00:00:00");
> >    Time2 := Ada.Calendar.Time_Of(1970,1,1,0.0);
>
> >    Put("Time1: ");Put(Image(Time1));New_Line;
> >    Put("Time2: ");Put(Image(Time2));New_Line;
>
> >    Put("UTC_Time_Offset: ");Put(Integer(UTC_Time_Offset),8);
>
> > This gives the following output on my computer:
>
> > Time1: 1970-01-01 00:00:00
> > Time2: 1969-12-31 23:00:00
> > UTC_Time_Offset:      120
>
> > The first line I now understand reflects that both "Value"
> > and "Image" has parameter Time_Zone = 0 (UTC). I.e. "Time1"
> > can be understood to have value 1970-01-01 00:00:00 (UTC).
> > "But "Time2" is 1970-01-01 00:00:00 *minus* one hour (only), and
> > UTC_Time_Offset = 120 (2 hours).
>
> I suspect you've recently gone on
> daylight-savings/summer/whatever-it's-called-where-you-are time, which is UTC
> +02:00 (120 mins), but on 1970 Jan 01 you were on regular time, which is UTC +01:00.
>
> --
> Jeff Carter
> "I don't know why I ever come in here. The
> flies get the best of everything."
> Never Give a Sucker an Even Break
> 102




  parent reply	other threads:[~2009-03-30 19:44 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
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 [this message]
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