GNAT.Calendard Example


with Ada.Calendar;

with GNAT.Calendar; use GNAT.Calendar;
with GNAT.Calendar.Time_IO;
with GNAT.IO; use GNAT.IO;


procedure GNAT_CAL is
   Now : Ada.Calendar.Time := Ada.Calendar.Clock;
begin
   Put_Line ("Hour :" & Hour (Now)'Img);
   Put_Line ("Minute :" & Minute (Now)'Img);
   Put_Line ("Second :" & Second (Now)'Img);
   Put_Line ("Sub_Second :" & Sub_Second (Now)'Img);
   Put_Line ("Day_Of_Week :" & Day_Of_Week (Now)'Img);
   Put_Line ("Day_In_Year :" & Day_In_Year (Now)'Img);
   Put_Line ("Week_In_Year :" & Week_In_Year (Now)'Img);

   GNAT.Calendar.Time_IO.Put_Time (Now,
                                   GNAT.Calendar.Time_IO.US_Date);

   New_Line;

   GNAT.Calendar.Time_IO.Put_Time (Now,
                                   "Today is %A, %B %d, %Y");

   New_Line;

end GNAT_CAL;

Contributed by: David Botton
Contributed on: September 2, 2001
License: Public Domain

Back