From: b.mcguinness747@gmail.com
Subject: Q: Calendar and time zones
Date: Mon, 29 Apr 2019 17:58:50 -0700 (PDT)
Date: 2019-04-29T17:58:50-07:00 [thread overview]
Message-ID: <16b6bd55-b734-40d9-a54b-6c41c9b60db1@googlegroups.com> (raw)
Section 9.6.1 of the Reference Manual has a note (39) at the bottom of the page that says: "Calling Split on the results of subtracting Duration(UTC_Time_Offset*60) from Clock provides the components (hours, minutes, and so on) of the UTC time. In the United States, for example, UTC_Time_Offset will generally be negative."
But several versions of Split have a Time_Zone argument that defaults to 0, which I interpret as meaning that they default to reporting the time in UTC. Moreover, I wrote a test program that seems to report UTC time properly without subtracting a time zone offset:
with Ada.Calendar, Ada.Calendar.Formatting, Ada.Calendar.Time_Zones, Ada.Text_IO;
procedure timetest is
use Ada.Calendar, Ada.Calendar.Formatting, Ada.Calendar.Time_Zones;
now : Time := Clock;
zone_offset : Time_Offset := UTC_Time_Offset (now);
begin
Ada.Text_IO.Put_Line ("Current time: " & Image (now) & " UTC");
Ada.Text_IO.Put_Line ("Current time: " & Image (now, false, zone_offset) & " local");
Ada.Text_IO.Put_Line ("Time zone offset: " & Time_Offset'Image (zone_offset) & " minutes");
end timetest;
$ timetest
Current time: 2019-04-30 00:55:19 UTC
Current time: 2019-04-29 20:55:19 local
Time zone offset: -240 minutes
Perhaps the comment refers only to versions of Split that do not take a Time_Zone argument.
It would be helpful if the comment in the Reference Manual was rewritten in future editions to indicate more clearly what it means.
--- Brian McGuinness
reply other threads:[~2019-04-30 0:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox