如何打印日历的日期

发布于 2024-08-17 23:44:35 字数 324 浏览 13 评论 0原文

我正在使用 Gnat(ada95 的旧编译器),但在打印日期时遇到问题。
我声明:(with Ada.calendar

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

现在我尝试打印它 -

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

但我没能做到......

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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好倦 2024-08-24 23:44:35

您只提供了程序片段,因此很难判断您实际编写的内容以及尝试运行的内容。而且你没有指出它“如何”不起作用。是不是没有编译通过?是否已编译但运行不正确?

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

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

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;

这是使用 Gnat 编译和运行的,虽然您可能使用它的旧版本,但它本身并不是“旧编译器”,它是最新/最好的免费版本GNAT GPL 2009 很容易获得。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文