1

我正在使用 Gnat(ada95 的旧编译器)并且在打印日期时遇到问题。
我宣布:(与 Ada.calendar)

Cdate:日历.时间;
Cdate:= Calendar.Time_Of(Year => 2010,Month => 1,Day => 10);

现在我尝试打印它-

Put_Line("年份:" & 年份(Cdate)'Img);

但是我没能做到……

4

1 回答 1

2

您只提供了程序片段,因此很难说出您实际编写并尝试运行的内容。而且您没有说明“如何”它不起作用。它没有编译吗?它是否编译但运行不正确?

如果从您的代码中按原样剪切片段并粘贴到此处,您可能会遇到语法错误。

这是一个完整的工作程序,可以执行您想要的操作:

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.

于 2010-01-11T14:30:55.940 回答