TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Corey Minyard <[log in to unmask]>
Sun, 28 Oct 2001 17:42:06 -0600
text/plain; charset=us-ascii; format=flowed
Corey Minyard <[log in to unmask]>
text/plain (48 lines)
I've been looking at calendar issues in Ada, I'm trying to write a
complete calendar package for Ada.  I'm trying to understand how
daylight savings works in Ada.Calendar.

An average day has 86_400 seconds (24 * 3600).  However, the day where
daylight savings time is activated would seem to have 82_800 seconds (23
* 3600) and the day where daylight savings time is deactivated, as just
happened in the US, would seem to have 90_000 seconds (25 * 3600).

I would seem to me that the seconds in the day would not be dependent on
daylight savings, but would instead range 0 .. 90_000.  Otherwise,
certain times cannot be represented properly in certain circumstances.
For instance, if you do the following:

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;

procedure T1 is
    Time1   : Time;
    Time2   : Time;
    Year1   : Year_Number;
    Month1  : Month_Number;
    Day1    : Day_Number;
    Seconds : Duration;
    Time1 := Time_Of(2001, 10, 28, 3600.0 * 1.5) + 3600.0;
    Split(Time1, Year1, Month1, Day1, Seconds);
    Time2 := Time_Of(Year1, Month1, Day1, Seconds);
    if (Time1 = Time2) then
       Put_Line("Times are equal");
       Put_Line("Times are unequal");
    end if;
end T1;

The times will not be equal (at least on GNAT-3.12p in a US timezone).
Is this the intent?  If so, there is no easy way to tell the two
"1:30AM" times apart from each other, because the calendar package gives
no way to tell if DST is active.  I guess you could figure out of DST
might active on that day and add an hour to see if you get the same
"seconds" value back, but that's kind of a pain.  I guess I'm used to
the Java calendar package, which is quite powerful and comples.  The
whole date/time things is a big mess, anyway.

Thanks for any insight on this.