tags:

views:

57

answers:

1

I'm using Gnat (old compiler of ada95) and I'm having problem to print the date.
I declaired : (with Ada.calendar)

Cdate: Calendar.Time;
Cdate:= Calendar.Time_Of(Year => 2010,Month => 1,Day => 10);

Now I've tried to print it -

Put_Line("Year : " & Year(Cdate)'Img);

But I didnt managed to do so...

+1  A: 

You only provided program fragments, so it's hard to tell what you actually wrote and are trying to run. And you didn't indicate "how" it didn't work. Did it not compile? Did it compile but not run correctly?

If the fragments were cut as-is from your code and pasted here, you've probably gotten syntax errors.

Here's a fully working program that does what you appear to want:

with Calendar;
with Text_IO; use Text_IO;

procedure Cdate_Test is

   Cdate : Calendar.Time;

begin
   Cdate := Calendar.Time_Of(Year => 2010, Month => 1, Day => 10);
   Put_Line("Year: " & Calendar.Year(Cdate)'Img);
end Cdate_Test;

This was compiled and run using Gnat, and while you may be using an old version of it, it is not itself an "old compiler", the latest/greatest free version of it, GNAT GPL 2009, is readily available.

Marc C