Day of the week of Christmas and New Year: Difference between revisions

→‎{{header|Ring}}: removed external library dependency, removed hard-coded date, this routine will now automatically work every year without having to modify it
(→‎{{header|Ring}}: removed external library dependency, removed hard-coded date, this routine will now automatically work every year without having to modify it)
Line 196:
 
=={{header|Ring}}==
<lang ring>? "working..."
weekdays = ["Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"]
see "working..." + nl
dow = timelist()[15]
today = date()
tycd = "25/12/" + substr(today, 7, 4)
nnyd = "01/01/" + string(number(substr(today, 7, 4)) + 1)
for day = 0 to 366
anotherday = adddays(today, day)
if anotherday = tycd
see ? "This year's Christmas day is on a " + weekdays[d1]nameof(day) + nl"."
ok
if anotherday = nnyd
? "The next New Year's day is on a " + nameof(day) + "."
exit
ok
next
seeput "done..." + nl
 
func nameof day
load "guilib.ring"
return weekdays[((day + today - 1) % 7) + 1] + "day"</lang>
weekdays = ["Monday","Tuesday","Wendesday","Thirsday","Friday","Saturday","Sunday"]
oDate1 = new QDate()
oDate2 = new QDate()
oDate1.setDate(2021,12,25)
oDate2.setDate(2022,1,1)
d1 = oDate1.dayOfWeek()
d2 = oDate2.dayOfWeek()
see "This year's Christmas is on a " + weekdays[d1] + nl
see "Next new year is on a " + weekdays[d2] + nl
see "done..." + nl
</lang>
{{out}}
<pre>working...
Next newThis year's Christmas day is on a Saturday.
working...
ThisThe yearnext New Year's Christmasday is on a Saturday.
done...</pre>
Next new year is on a Saturday
done...
</pre>
 
=={{header|Wren}}==