From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,aa60d56d22a287d1 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!postnews.google.com!v19g2000yqn.googlegroups.com!not-for-mail From: reinkor Newsgroups: comp.lang.ada Subject: Re: Newbie Q: How to program in UTC (time/calendar) ? Date: Mon, 30 Mar 2009 12:44:05 -0700 (PDT) Organization: http://groups.google.com Message-ID: <23cd155b-b8e8-4f53-b411-10eb2ce67a3f@v19g2000yqn.googlegroups.com> References: <7f003dc4-3c3c-4e47-8ddf-d5001b310c17@g38g2000yqd.googlegroups.com> <8aad6593-efb8-441f-9eac-27cf2fe7a124@v38g2000yqb.googlegroups.com> NNTP-Posting-Host: 80.212.35.48 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1238442245 14803 127.0.0.1 (30 Mar 2009 19:44:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 30 Mar 2009 19:44:05 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: v19g2000yqn.googlegroups.com; posting-host=80.212.35.48; posting-account=bPTmZAoAAAC_6HP9XLKB9aAAxBa6BuOR User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.64 (X11; Linux x86_64; U; en) Presto/2.1.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:4390 Date: 2009-03-30T12:44:05-07:00 List-Id: Thanks to all. Now I think I got it ! And giving the argument "Time1" to UTC_Time_Offset" like this: =A0UTC_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: =A0 =A0 =A0 60 Lesson learned: "remember the argument for UTC_Time_Offset" ! =A0 :-) reinert PS, new program code: ---------------------------------------------------------------------------= -- with Text_IO; use =A0Text_IO; with Ada.Calendar.Formatting,Ada.Calendar.Time_Zones; -- with Ada.Calendar.Aritmetric; use =A0Ada.Calendar,Ada.Calendar.Formatting,Ada.Calendar.Time_Zones; procedure t1 is =A0 =A0package Int_Io =A0is new Text_IO.Integer_Io (Integer); =A0 =A0use Int_Io; =A0 =A0Time1,Time2 : Time; begin =A0 =A0Time1 :=3D Value("1970-01-01 00:00:00"); =A0 =A0Time2 :=3D Ada.Calendar.Time_Of(1970,1,1,0.0); =A0 =A0Put("Time1: ");Put(Image(Time1));New_Line; =A0 =A0Put("Time2: ");Put(Image(Time2));New_Line; =A0 =A0Put("UTC_Time_Offset: ");Put(Integer(UTC_Time_Offset(Time1)),8); end t1; On 30 Mar, 18:52, "Jeffrey R. Carter" wrote: > reinkor wrote: > > =A0 =A0Time1 :=3D Value("1970-01-01 00:00:00"); > > =A0 =A0Time2 :=3D Ada.Calendar.Time_Of(1970,1,1,0.0); > > > =A0 =A0Put("Time1: ");Put(Image(Time1));New_Line; > > =A0 =A0Put("Time2: ");Put(Image(Time2));New_Line; > > > =A0 =A0Put("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: =A0 =A0 =A0120 > > > The first line I now understand reflects that both "Value" > > and "Image" has parameter Time_Zone =3D 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 =3D 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