* Re: Ada.Calendar."+" gives peculiar result (Gnat 3.13)
2001-07-04 3:29 Ada.Calendar."+" gives peculiar result (Gnat 3.13) Charles Darcy
@ 2001-07-03 13:42 ` Ian Wild
2001-07-04 1:16 ` Charles Darcy
2001-07-03 13:49 ` Karel Thönissen
1 sibling, 1 reply; 5+ messages in thread
From: Ian Wild @ 2001-07-03 13:42 UTC (permalink / raw)
Charles Darcy wrote:
>
> Hello,
>
> I've been using the Ada.Calendar.Time type to represent dates in my
> program, and have struck a problem.
>
> Within a loop, I add (7 * Ada.Calendar.Day_Duration'Last) to an
> Ada.Calendar.Time object, at the end of each iteration. I expected this
> to advance the time by 1 week, and so it does initially. After a number
> of loop iterations, however, the addition seems to advance the time by 1
> week and 1 hour.
Daylight savings time?
Odd thing is, it seems to be using US rules, and
you're posting from .au, so I'd've expected the
anomalies to happen in the opposite order.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada.Calendar."+" gives peculiar result (Gnat 3.13)
2001-07-04 3:29 Ada.Calendar."+" gives peculiar result (Gnat 3.13) Charles Darcy
2001-07-03 13:42 ` Ian Wild
@ 2001-07-03 13:49 ` Karel Thönissen
2001-07-04 4:00 ` Charles Darcy
1 sibling, 1 reply; 5+ messages in thread
From: Karel Thönissen @ 2001-07-03 13:49 UTC (permalink / raw)
Charles Darcy schreef:
>
> Hello,
>
> I've been using the Ada.Calendar.Time type to represent dates in my
> program, and have struck a problem.
>
> Within a loop, I add (7 * Ada.Calendar.Day_Duration'Last) to an
> Ada.Calendar.Time object, at the end of each iteration. I expected this
> to advance the time by 1 week, and so it does initially. After a number
> of loop iterations, however, the addition seems to advance the time by 1
> week and 1 hour.
[code snipped]
> Any ideas as to what is going on ? In case its relevant, I'm using Gnat
> 3.13p under Linux.
Daylight-saving / summertime.
--
Groeten, Karel Th�nissen
Hello Technologies develops high-integrity software for complex systems
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada.Calendar."+" gives peculiar result (Gnat 3.13)
2001-07-03 13:42 ` Ian Wild
@ 2001-07-04 1:16 ` Charles Darcy
0 siblings, 0 replies; 5+ messages in thread
From: Charles Darcy @ 2001-07-04 1:16 UTC (permalink / raw)
Ian Wild wrote:
>
> Charles Darcy wrote:
> >
> > Hello,
> >
> > I've been using the Ada.Calendar.Time type to represent dates in my
> > program, and have struck a problem.
> >
> > Within a loop, I add (7 * Ada.Calendar.Day_Duration'Last) to an
> > Ada.Calendar.Time object, at the end of each iteration. I expected this
> > to advance the time by 1 week, and so it does initially. After a number
> > of loop iterations, however, the addition seems to advance the time by 1
> > week and 1 hour.
>
> Daylight savings time?
Yes, the problem seems related to Daylight Savings Time. The dates on
which the extra hour appears and disappears, correspond to DST begin/end
dates.
>
> Odd thing is, it seems to be using US rules, and
> you're posting from .au, so I'd've expected the
> anomalies to happen in the opposite order.
I've just checked the Linux system time zone and found it set to
Abidjan, Africa. I set the correct zone (NSW, Australia), re-run the
test, and found that the additional hour has disappeared altogether. The
time now advances one week exactly, irrespective of whether daylight
savings time is in effect.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Ada.Calendar."+" gives peculiar result (Gnat 3.13)
@ 2001-07-04 3:29 Charles Darcy
2001-07-03 13:42 ` Ian Wild
2001-07-03 13:49 ` Karel Thönissen
0 siblings, 2 replies; 5+ messages in thread
From: Charles Darcy @ 2001-07-04 3:29 UTC (permalink / raw)
Hello,
I've been using the Ada.Calendar.Time type to represent dates in my
program, and have struck a problem.
Within a loop, I add (7 * Ada.Calendar.Day_Duration'Last) to an
Ada.Calendar.Time object, at the end of each iteration. I expected this
to advance the time by 1 week, and so it does initially. After a number
of loop iterations, however, the addition seems to advance the time by 1
week and 1 hour.
Below is code which demonstrates the problem:
declare
use Ada.Text_IO;
use Ada.Calendar;
The_Year : Year_Number;
The_Month : Month_Number;
The_Day : Day_Number;
The_Seconds : Day_Duration;
The_Date : Time := Time_Of (1995, 12, 2);
begin
for Count in 1 .. 100 loop
Put_Line ("");
Put_Line ("Iteration: " & Integer'Image (Count));
Split (The_Date, The_Year, The_Month, The_Day, The_Seconds);
Put_Line ("The_Date:");
Put_Line (" year: " & Year_Number'Image (The_Year));
Put_Line (" month: " & Month_Number'Image (The_Month));
Put_Line (" day: " & Day_Number'Image (The_Day));
Put_Line (" seconds: " & Day_Duration'Image (The_Seconds));
The_Date := The_Date + 7 * Ada.Calendar.Day_Duration'Last;
end loop;
end;
The output begins with ...
Iteration: 1
The_Date:
year: 1995
month: 12
day: 2
seconds: 0.000000000
Iteration: 2
The_Date:
year: 1995
month: 12
day: 9
seconds: 0.000000000
Iteration: 3
The_Date:
year: 1995
month: 12
day: 16
seconds: 0.000000000
... which is as I expected. However, later on ...
Iteration: 19
The_Date:
year: 1996
month: 4
day: 6
seconds: 0.000000000
Iteration: 20
The_Date:
year: 1996
month: 4
day: 13
seconds: 3600.000000000
Iteration: 21
The_Date:
year: 1996
month: 4
day: 20
seconds: 3600.000000000
... an additional hour (the 3600 seconds) seems to have been added.
Still later, the additional hour disappears ...
Iteration: 48
The_Date:
year: 1996
month: 10
day: 26
seconds: 3600.000000000
Iteration: 49
The_Date:
year: 1996
month: 11
day: 2
seconds: 0.000000000
Iteration: 50
The_Date:
year: 1996
month: 11
day: 9
seconds: 0.000000000
Any ideas as to what is going on ? In case its relevant, I'm using Gnat
3.13p under Linux.
regards,
Charles.
P.S. Can anyone recommend a good Date package ?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ada.Calendar."+" gives peculiar result (Gnat 3.13)
2001-07-03 13:49 ` Karel Thönissen
@ 2001-07-04 4:00 ` Charles Darcy
0 siblings, 0 replies; 5+ messages in thread
From: Charles Darcy @ 2001-07-04 4:00 UTC (permalink / raw)
Karel Th�nissen wrote:
>
> Charles Darcy schreef:
> >
> > Hello,
> >
> > I've been using the Ada.Calendar.Time type to represent dates in my
> > program, and have struck a problem.
> >
> > Within a loop, I add (7 * Ada.Calendar.Day_Duration'Last) to an
> > Ada.Calendar.Time object, at the end of each iteration. I expected this
> > to advance the time by 1 week, and so it does initially. After a number
> > of loop iterations, however, the addition seems to advance the time by 1
> > week and 1 hour.
>
> [code snipped]
>
> > Any ideas as to what is going on ? In case its relevant, I'm using Gnat
> > 3.13p under Linux.
>
> Daylight-saving / summertime.
Of course. Thanks (and sorry for being dense).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-07-04 4:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-04 3:29 Ada.Calendar."+" gives peculiar result (Gnat 3.13) Charles Darcy
2001-07-03 13:42 ` Ian Wild
2001-07-04 1:16 ` Charles Darcy
2001-07-03 13:49 ` Karel Thönissen
2001-07-04 4:00 ` Charles Darcy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox