firestruq
firestruq

Reputation: 739

how to print date of calendar

I'm using Gnat (old compiler of ada95) and I'm having problem to print the date.
I declared : (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 didn't managed to do so...

Upvotes: 1

Views: 452

Answers (1)

Marc C
Marc C

Reputation: 8522

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.

Upvotes: 2

Related Questions