Day of the week of Christmas and New Year: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add BASIC) |
Not a robot (talk | contribs) (Add BCPL) |
||
Line 128: | Line 128: | ||
<pre>12/25/2021 is a Saturday |
<pre>12/25/2021 is a Saturday |
||
1/ 1/2022 is a Saturday</pre> |
1/ 1/2022 is a Saturday</pre> |
||
=={{header|BCPL}}== |
|||
<lang bcpl>get "libhdr" |
|||
let dayofweek(y,m,d) = valof |
|||
$( let j, k = ?, ? |
|||
if m<=2 |
|||
$( m := m+12 |
|||
y := y-1 |
|||
$) |
|||
j := y/100 |
|||
k := y rem 100 |
|||
d := (d + ((m+1)*26)/10 + k + k/4 + j/4 + 5*j) rem 7 |
|||
switchon d into |
|||
$( case 0: resultis "Saturday" |
|||
case 1: resultis "Sunday" |
|||
case 2: resultis "Monday" |
|||
case 3: resultis "Tuesday" |
|||
case 4: resultis "Wednesday" |
|||
case 5: resultis "Thursday" |
|||
case 6: resultis "Friday" |
|||
$) |
|||
$) |
|||
let show(y,m,d) be |
|||
writef("%N/%N/%N is a %S*N", m, d, y, dayofweek(y, m, d)) |
|||
let start() be |
|||
$( show(2021,12,25) |
|||
show(2022,1,1) |
|||
$)</lang> |
|||
{{out}} |
|||
<pre>12/25/2021 is a Saturday |
|||
1/1/2022 is a Saturday</pre> |
|||
=={{header|CLU}}== |
=={{header|CLU}}== |