Day of the week: Difference between revisions
Content deleted Content added
No edit summary |
m Fixed lang tags. |
||
Line 7:
=={{header|Ada}}==
<lang ada>with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;▼
<lang ada>▼
▲with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
with Ada.Text_IO; use Ada.Text_IO;
Line 18 ⟶ 17:
end if;
end loop;
end Yuletide;</lang>
</lang>▼
Sample output:
<pre style="height:30ex;overflow:scroll">
Line 99 ⟶ 97:
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
{{works with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386}}
<lang algol68>main:(
# example from: http://www.xs4all.nl/~jmvdveer/algol.html - GPL #
INT sun=0 # , mon=1, tue=2, wed=3, thu=4, fri=5, sat=6 #;
Line 121 ⟶ 118:
OD;
new line(stand out)
Output:
<lang algol68>December 25th is a Sunday in: 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118</lang>▼
▲December 25th is a Sunday in: 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
=={{header|AutoHotkey}}==
Line 181 ⟶ 175:
=={{header|C++}}==
<lang cpp>#include <boost/date_time/gregorian/gregorian.hpp>▼
<lang C++>▼
▲#include <boost/date_time/gregorian/gregorian.hpp>
#include <iostream>
Line 199 ⟶ 192:
std::cout << "\n" ;
return 0 ;
▲}</lang>
</lang>▼
This produces the following output:
<pre>
Line 300 ⟶ 292:
=={{header|D}}==
I'm sure this can be done better. If anyone wants to take the time, please improve it.
<lang d>import std.date;
import std.stdio;
void main() {
Line 307 ⟶ 298:
if (0 == WeekDay(parse("December 25, "~std.string.toString(year))))
writefln("Christmas comes on a sunday in %d",year);
=={{header|Forth}}==
Forth has only TIME&DATE, which does not give day of week. Many public Forth Julian date calculators had year-2100 problems, but this algorithm works well.
=={{header|Fortran}}==
Line 438 ⟶ 428:
=={{header|J}}==
<lang j> load 'dates' NB. provides verb 'weekday'
=={{header|Java}}==
Line 508 ⟶ 498:
=={{header|M4}}==
<lang M4>divert(-1)
define(`for',
Line 527 ⟶ 516:
for(`yr',2008,2121,
`ifelse(eval(julianxmas(yr)%7==6),1,`yr ')')</lang>
Output:
Line 537 ⟶ 525:
=={{header|Mathematica}}==
▲ Reap[If[DateString[{#,12,25},"DayName"]=="Sunday",Sow[#]]&/@Range[2008,2121]][[2,1]]
gives back:
▲ {2011,2016,2022,2033,2039,2044,2050,2061,2067,2072,2078,2089,2095,2101,2107,2112,2118}
=={{header|Modula-3}}==
Line 760 ⟶ 744:
}
}
?></lang>
Output:
Line 817 ⟶ 800:
=={{header|R}}==
<lang R>years <- 2008:2121
xmas <- as.POSIXlt(paste(years, '/12/25', sep=""))
years[xmas$wday==0]</lang>
2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
Line 935 ⟶ 916:
=={{header|UNIX Shell}}==
{{works with|bash}}
<
for i in `seq 2008 2121`
Line 942 ⟶ 923:
done
exit 0</lang>
The first lines of output (from a 32bit GNU/Linux system, date version 6.9) are
<lang bash>Sun Dec 25 00:00:00 CET 2011▼
▲Sun Dec 25 00:00:00 CET 2011
Sun Dec 25 00:00:00 CET 2016
Sun Dec 25 00:00:00 CET 2022
Sun Dec 25 00:00:00 CET 2033
date: invalid date `2038-12-25'</lang>
I.e., starting from year 2038, the <tt>date</tt> command (which uses the glibc library, at least on GNU systems), is not able to recognise the date as a valid one!
Line 959 ⟶ 937:
===Different machine/OS version (64 bit)===
This is the same command run on RedHat Linux.
<
date (coreutils) 5.2.1
Written by David MacKenzie.
Line 986 ⟶ 964:
Sun Dec 25 00:00:00 GMT 2112
Sun Dec 25 00:00:00 GMT 2118
bash-3.00$</
=={{header|UnixPipes}}==
Thanks to UNIX Shell implementation
(Output same as UNIX Shell)
=={{header|Vedit macro language}}==
<lang vedit>Buf_Switch(Buf_Free)
for (#3 = 2008; #3 < 2122; #3++) {
Reg_Set(10, "12/25/")
Line 1,003 ⟶ 980:
Num_Ins(#3, NOCR)
}
▲}</lang>
Output:
|