Jump to content

Day of the week: Difference between revisions

Rename Perl 6 -> Raku, alphabetize, minor clean-up
(→‎{{header|Vlang}}: fixed example to handle option return from time.parse, so that it could compile)
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 188:
2118
</pre>
 
 
=={{header|Ada}}==
Line 869 ⟶ 868:
return 0;
}</lang>
 
=={{header|C++}}==
<lang cpp>#include <boost/date_time/gregorian/gregorian.hpp>
#include <iostream>
 
int main( ) {
using namespace boost::gregorian ;
 
std::cout
<< "Yuletide holidays must be allowed in the following years:\n" ;
for ( int i = 2008 ; i < 2121 ; i++ ) {
greg_year gy = i ;
date d ( gy, Dec , 25 ) ;
if ( d.day_of_week( ) == Sunday ) {
std::cout << i << std::endl ;
}
}
std::cout << "\n" ;
return 0 ;
}</lang>
{{out}}
<pre>
Yuletide holidays must be allowed in the following years:
2011
2016
2022
2033
2039
2044
2050
2061
2067
2072
2078
2089
2095
2101
2107
2112
2118
</pre>
 
=={{header|C sharp|C#}}==
Line 976 ⟶ 934:
25 Dec 2112
25 Dec 2118</pre>
 
=={{header|C++}}==
<lang cpp>#include <boost/date_time/gregorian/gregorian.hpp>
#include <iostream>
 
int main( ) {
using namespace boost::gregorian ;
 
std::cout
<< "Yuletide holidays must be allowed in the following years:\n" ;
for ( int i = 2008 ; i < 2121 ; i++ ) {
greg_year gy = i ;
date d ( gy, Dec , 25 ) ;
if ( d.day_of_week( ) == Sunday ) {
std::cout << i << std::endl ;
}
}
std::cout << "\n" ;
return 0 ;
}</lang>
{{out}}
<pre>
Yuletide holidays must be allowed in the following years:
2011
2016
2022
2033
2039
2044
2050
2061
2067
2072
2078
2089
2095
2101
2107
2112
2118
</pre>
 
=={{header|Clojure}}==
Line 1,483 ⟶ 1,482:
2118
</pre>
 
 
=={{header|F_Sharp|F#}}==
Line 1,513 ⟶ 1,511:
PAUSE
</lang>
 
=={{header|Fōrmulæ}}==
 
In [https://wiki.formulae.org/Day_of_the_week this] page you can see the solution of this task.
 
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text ([http://wiki.formulae.org/Editing_F%C5%8Drmul%C3%A6_expressions more info]). Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for transportation effects more than visualization and edition.
 
The option to show Fōrmulæ programs and their results is showing images. Unfortunately images cannot be uploaded in Rosetta Code.
 
=={{header|Forth}}==
Line 1,615 ⟶ 1,605:
25th of December is a Sunday in 2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118
</pre>
 
=={{header|Fōrmulæ}}==
 
In [https://wiki.formulae.org/Day_of_the_week this] page you can see the solution of this task.
 
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text ([http://wiki.formulae.org/Editing_F%C5%8Drmul%C3%A6_expressions more info]). Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for transportation effects more than visualization and edition.
 
The option to show Fōrmulæ programs and their results is showing images. Unfortunately images cannot be uploaded in Rosetta Code.
 
=={{header|Gambas}}==
Line 2,424 ⟶ 2,422:
2118
</pre>
 
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
Line 2,471 ⟶ 2,468:
lambda([y], weekday(y, 12, 25) = 'sunday));
/* [2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118] */</lang>
 
=={{header|МК-61/52}}==
<lang>П9 7 П7 1 П8 НОП ИП8 2 2 -
1 0 / [x] П6 ИП9 + 1 8 9
9 - 3 6 5 , 2 5 * [x]
ИП8 ИП6 1 2 * - 1 4 - 3
0 , 5 9 * [x] + 2 9 +
ИП7 + П4 ИП4 7 / [x] 7 * -
x=0 64 ИП9 С/П ИП9 1 + П9 БП 06</lang>
 
''Input:'' РX: starting year.
 
''Output:'' the year in which Christmas falls on a Sunday. For example, enter ''2008'', the first result: ''2018'' (''January 7, 2018'' is Sunday).
 
=={{header|Modula-3}}==
Line 2,515 ⟶ 2,525:
2038 is the last year we can specify
</pre>
 
=={{header|МК-61/52}}==
<lang>П9 7 П7 1 П8 НОП ИП8 2 2 -
1 0 / [x] П6 ИП9 + 1 8 9
9 - 3 6 5 , 2 5 * [x]
ИП8 ИП6 1 2 * - 1 4 - 3
0 , 5 9 * [x] + 2 9 +
ИП7 + П4 ИП4 7 / [x] 7 * -
x=0 64 ИП9 С/П ИП9 1 + П9 БП 06</lang>
 
''Input:'' РX: starting year.
 
''Output:'' the year in which Christmas falls on a Sunday. For example, enter ''2008'', the first result: ''2018'' (''January 7, 2018'' is Sunday).
 
=={{header|MUMPS}}==
Line 3,218 ⟶ 3,215:
{{out}}
<pre>2011 2016 2022 2033 2039 2044 2050 2061 2067 2072 2078 2089 2095 2101 2107 2112 2118</pre>
 
=={{header|Perl 6}}==
 
{{works with|Rakudo|2010.07}}
 
As Perl 5, except <code>DateTime</code> is built-in, so you don't need to download a module of that name:
 
<lang perl6>say join ' ', grep { Date.new($_, 12, 25).day-of-week == 7 }, 2008 .. 2121;</lang>
 
=={{header|Phix}}==
Line 3,594 ⟶ 3,583:
(displayln y))
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
 
{{works with|Rakudo|2010.07}}
 
As Perl 5, except <code>DateTime</code> is built-in, so you don't need to download a module of that name:
 
<lang perl6>say join ' ', grep { Date.new($_, 12, 25).day-of-week == 7 }, 2008 .. 2121;</lang>
 
=={{header|REBOL}}==
Line 3,663 ⟶ 3,661:
>>
</pre>
 
=={{header|REXX}}==
===using DATE weekday===
Line 3,871 ⟶ 3,870:
<pre>Years = [2011, 2016, 2022, 2033, 2039, 2044, 2050, 2061, 2067, 2072, 2078, 2089, 2095, 2101, 2107, 2112, 2118]
</pre>
 
=={{header|SAS}}==
<lang sas>data _null_;
do y=2008 to 2121;
a=mdy(12,25,y);
if weekday(a)=1 then put y;
end;
run;
 
/* 2011 2016 2022 2033 2039 2044 2050 2061 2067
2072 2078 2089 2095 2101 2107 2112 2118 */</lang>
 
=={{header|S-BASIC}}==
Line 3,938 ⟶ 3,926:
2112
2118</pre>
 
=={{header|SAS}}==
<lang sas>data _null_;
do y=2008 to 2121;
a=mdy(12,25,y);
if weekday(a)=1 then put y;
end;
run;
 
/* 2011 2016 2022 2033 2039 2044 2050 2061 2067
2072 2078 2089 2095 2101 2107 2112 2118 */</lang>
 
=={{header|Scala}}==
Line 4,178 ⟶ 4,177:
 
17 rows selected.</pre>
 
=={{header|Standard ML}}==
<lang sml>(* Call: yearsOfSundayXmas(2008, 2121) *)
fun yearsOfSundayXmas(fromYear, toYear) =
if fromYear>toYear then
()
else
let
val d = Date.date {year=fromYear, month=Date.Dec, day=25,
hour=0, minute=0, second=0,
offset=SOME Time.zeroTime}
val wd = Date.weekDay d
in
if wd=Date.Sun then
(
print(Int.toString fromYear ^ "\n");
yearsOfSundayXmas(fromYear+1, toYear)
)
else
yearsOfSundayXmas(fromYear+1, toYear)
end;</lang>
 
{{out}}
<pre>- yearsOfSundayXmas(2008, 2121);
2011
2016
2022
2033
2039
2044
2050
2061
2067
2072
2078
2089
2095
2101
2107
2112
2118</pre>
 
=={{header|Stata}}==
Line 4,241 ⟶ 4,281:
2112
2118</pre>
=={{header|Standard ML}}==
<lang sml>(* Call: yearsOfSundayXmas(2008, 2121) *)
fun yearsOfSundayXmas(fromYear, toYear) =
if fromYear>toYear then
()
else
let
val d = Date.date {year=fromYear, month=Date.Dec, day=25,
hour=0, minute=0, second=0,
offset=SOME Time.zeroTime}
val wd = Date.weekDay d
in
if wd=Date.Sun then
(
print(Int.toString fromYear ^ "\n");
yearsOfSundayXmas(fromYear+1, toYear)
)
else
yearsOfSundayXmas(fromYear+1, toYear)
end;</lang>
 
{{out}}
<pre>- yearsOfSundayXmas(2008, 2121);
2011
2016
2022
2033
2039
2044
2050
2061
2067
2072
2078
2089
2095
2101
2107
2112
2118</pre>
 
 
 
=={{header|Swift}}==
Line 4,764 ⟶ 4,762:
2017-12-05 :Tuesday
</pre>
 
=={{header|ZX Spectrum Basic}}==
{{trans|BASIC}}
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.