Anonymous user
Last Friday of each month: Difference between revisions
→{{header|Ada}}: implemented a general solution where the weekday is part of the input, also the previous solution was wrong if Feb. 29 was a Friday (in a leap year, of course)
(changed wordcase of "find last sunday of each month" to match actual title of same. -- ~~~~) |
(→{{header|Ada}}: implemented a general solution where the weekday is part of the input, also the previous solution was wrong if Feb. 29 was a Friday (in a leap year, of course)) |
||
Line 24:
=={{header|Ada}}==
Uses GNAT.
with Ada.Calendar; use Ada.Calendar;▼
<lang Ada>with Ada.Text_IO, GNAT.Calendar.
Ada.Calendar.Formatting, Ada.Calendar.Arithmetic;
T : Ada.Calendar.Time;▼
procedure Last_Weekday_In_Month is
Year : Year_Number := Integer'Value (Argument (1));▼
use GNAT.Calendar.Time_IO;
begin
end Put_Line;
subtype Day_Name is Formatting.Day_Name; use type Formatting.Day_Name;
T, Selected : Time;
Weekday: Day_Name := Day_Name'Value(Ada.Command_Line.Argument (1));
begin
for
T := Time_Of (Year => Year, Month => Month, Day => 01);
Selected := T;
▲ Put_Line (Image (Date => T)(1 .. 10)); exit;
T := T + Day_Count(1);
end loop;
Put_Line(Selected);
end loop;
end
{{out}}
<pre>>./
2012-01-27
2012-02-24
|