comp.lang.ada
 help / color / mirror / Atom feed
* Ada, calendar, and daylight savings
@ 2001-10-28 23:41 Corey Minyard
  2001-10-28 23:53 ` Larry Kilgallen
  2001-10-29  2:34 ` Steven Deller
  0 siblings, 2 replies; 21+ messages in thread
From: Corey Minyard @ 2001-10-28 23:41 UTC (permalink / raw)


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;
begin
    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");
    else
       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.

-Corey




^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2001-11-01  0:13 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-28 23:41 Ada, calendar, and daylight savings Corey Minyard
2001-10-28 23:53 ` Larry Kilgallen
2001-10-29  3:44   ` Corey Minyard
2001-10-29 10:17     ` Larry Kilgallen
2001-10-29 14:02       ` Corey Minyard
2001-10-29 14:35     ` Marin David Condic
2001-10-29  2:34 ` Steven Deller
2001-10-29  3:51   ` tmoran
2001-10-29  5:53     ` Corey Minyard
2001-10-29  6:49       ` tmoran
2001-10-29 10:21       ` Larry Kilgallen
2001-10-29 14:18         ` Corey Minyard
2001-10-29 23:15           ` tmoran
2001-10-30  2:07             ` Corey Minyard
2001-10-30  3:11               ` tmoran
2001-11-01  0:13                 ` Al Christians
2001-10-30 12:29               ` Larry Kilgallen
2001-10-29 14:48       ` Marin David Condic
2001-10-29 17:41         ` Corey Minyard
2001-10-30  2:19           ` Nick Roberts
2001-10-30  5:41             ` Al Christians

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