comp.lang.ada
 help / color / mirror / Atom feed
* Q: Calendar and time zones
@ 2019-04-30  0:58 b.mcguinness747
  0 siblings, 0 replies; only message in thread
From: b.mcguinness747 @ 2019-04-30  0:58 UTC (permalink / 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-30  0:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-30  0:58 Q: Calendar and time zones b.mcguinness747

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox