Day of the week: Difference between revisions
Content added Content deleted
(→{{header|Haskell}}: Updated system.time version output for 64bit systems and current GHC builds (+ hlint hindent)) |
(Added code for the Action! language (Optimized Systems Software, Atari 8-bit computers)) |
||
Line 124: | Line 124: | ||
2118 |
2118 |
||
</pre> |
</pre> |
||
=={{header|Action!}}== |
|||
Action! does not have a standard library providing a day of week function, therefore an adaptation of [https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Sakamoto.27s_methods Sakamoto's method] to determine the day of week for a given date using integer arithmetic is used. |
|||
<lang Action!> |
|||
Byte FUNC DayOfWeek(BYTE day, month CARD year BYTE century) |
|||
CARD weekday |
|||
BYTE ARRAY index=[0 3 2 5 0 3 5 1 4 6 2 4] |
|||
IF year < 100 THEN |
|||
year = year + century * 100 |
|||
FI |
|||
IF year < 1753 THEN RETURN(7) FI |
|||
IF month < 3 THEN |
|||
year==-1 |
|||
FI |
|||
month = index(month-1) |
|||
weekday=year + year/4 - year/100 + year/400 + month + day |
|||
weekday = weekday MOD 7 |
|||
RETURN (weekday) |
|||
PROC main() |
|||
CARD y |
|||
PrintE("December 25 is a Sunday in:") |
|||
FOR y = 2008 to 2121 |
|||
DO |
|||
IF DayOfWeek(25, 12, y)=0 THEN |
|||
PrintCE(y) |
|||
FI |
|||
OD |
|||
RETURN |
|||
</lang> |
|||
{{out}} |
|||
<pre style="height:30ex;overflow:scroll"> |
|||
December 25 is a Sunday in: |
|||
2011 |
|||
2016 |
|||
2022 |
|||
2033 |
|||
2039 |
|||
2044 |
|||
2050 |
|||
2061 |
|||
2067 |
|||
2072 |
|||
2078 |
|||
2089 |
|||
2095 |
|||
2101 |
|||
2107 |
|||
2112 |
|||
2118 |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |