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 04:27:18 -0700 (PDT)
Date: 2009-03-30T04:27:18-07:00	[thread overview]
Message-ID: <8ba0ccec-1b4a-4908-bfa3-1af471aa1798@e21g2000yqb.googlegroups.com> (raw)
In-Reply-To: XA7zl.630044$yE1.557332@attbi_s21

Thanks for clarifying.

I thought "Offset" was reletive to UTC - not relative
to the "local" time.

So

   Time1 := Value("1970-01-01 00:00:00",Time_Zone => UTC_Time_Offset);

gives UTC for the local "input" time "1970-01-01 00:00:00" ?

How do I best "input"/enter UTC time (so a reader of the program
also understand it - an independent of the computer local time)?

reinert

On 27 Mar, 18:58, "Jeffrey R. Carter"
<spam.jrcarter....@nospam.acm.org> wrote:
> reinkor wrote:
> >    Time1 := Value("1970-01-01 00:00:00");
> >    Put(Image(Time1));New_Line;
> >    Put(Image(Ada.Calendar.Time_Of(1970,1,1,Duration(0))));
>
> > 1970-01-01 00:00:00
> > 1969-12-31 23:00:00
>
> > The last output line here reflects the fact that Ada takes
> > "local time" from the computer - and the result would be
> > different if I wait to run my program till next Monday
> > (this weekend we change to summer daylight saving time).
>
> No. It reflects the fact that Image takes an Ada.Calendar.Time_Zones.Time_Offset
> parameter (Time_Zone) that defaults to 0 (UTC). Image is therefore converting
> the supplied time from your computer's offset
> (Ada.Calendar.Time_Zones.UTC_Time_Offset) to the default offset of 0. Your
> offset seems to be 60 (GMT + 1 hr). To get the image of what you passed to it,
> you must specify an offset of UTC_Time_Offset.
>
> The 1st value comes out as expected because Value also takes an
> Ada.Calendar.Time_Zones.Time_Offset parameter (Time_Zone) that defaults to 0
> (UTC). It is therefore taking the supplied string, interpreting it as a time in
> UTC, and converting it to the corresponding time for your computer's offset
> (UTC_Time_Offset). When you pass this time to Image with the default for
> Time_Zone, the conversion is then reversed as described above.
>
> You can compare the representations provided by Image with the values obtained
> by Ada.Calendar.Split to observe the conversions that the operations in
> Ada.Calendar.Formatting perform.
>
> Two comments on your code: "with Ada.Calendar.Formatting;" makes Ada,
> Ada.Calendar, and Ada.Calendar.Formatting visible; there is no need to also with
> Ada.Calendar.
>
> I cannot understand why you would say "Duration (0)" when "0.0" is clearer and
> shorter.
>
> --
> Jeff Carter
> "My mind is a raging torrent, flooded with rivulets of
> thought, cascading into a waterfall of creative alternatives."
> Blazing Saddles
> 89




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