Anonymous user
Day of the week: Difference between revisions
→{{header|Modula-3}}
(Modula-3 (and I finally remembered to log in :))) |
|||
Line 298:
=={{header|Modula-3}}==
{{trans|
Modula-3 represents time using a (safe) wrapper around the C time interface.
Consequently, it suffers from the same problem as C.
<pre>
MODULE Yule EXPORTS Main;
IMPORT IO, Fmt, Date, Time;
VAR date: Date.T;
BEGIN
IO.Put("25th of December is a Sunday in ");▼
FOR year := 2008 TO 2121 DO
date.day := 25;
date.month := Date.Month.Dec;
IO.Put(Fmt.Int(year) & " ");▼
date.year := year;
TRY
time := Date.ToTime(date);
EXCEPT
| Date.Error =>
▲ IO.Put(Fmt.Int(year) & " is the last year we can specify\n");
EXIT;
END;
date := Date.FromTime(time);
IF date.weekDay = Date.WeekDay.Sun THEN
IO.Put("25th of December " & Fmt.Int(year) & " is Sunday\n");
END;
END;
END Yule.
</pre>
Line 324 ⟶ 336:
Output:
<pre>
25th of December 2011 is
25th of December 2022 is Sunday
25th of December 2033 is Sunday
2038 is the last year we can specify
</pre>
|