Day of the week of Christmas and New Year: Difference between revisions
(Added Wren) |
(Tidied task description.) |
||
Line 3:
;Task:
<br>
=={{header|Python}}==
<lang python>
|
Revision as of 11:20, 24 November 2021
- Task
Determine programatically and show on this page on what weekday Christmas Day, 2021 and New Year's Day, 2022 will fall or did fall.
Python
<lang python> iimport datetime
weekDays = ("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday") thisXMas = datetime.date(2021,12,25) thisXMasDay = thisXMas.weekday() thisXMasDayAsString = weekDays[thisXMasDay] print("This year's Christmas is on a {}".format(thisXMasDayAsString))
nextNewYear = datetime.date(2022,1,1) nextNewYearDay = nextNewYear.weekday() nextNewYearDayAsString = weekDays[nextNewYearDay+1] print("Next new year is on a {}".format(nextNewYearDayAsString)) </lang>
- Output:
This year's Christmas is on a Saturday Next new year is on a Sunday
Wren
<lang ecmascript>import "./date" for Date
var xmas = Date.new(2021, 12, 25) // xmas and new year's weekdays are always the same var weekday = xmas.weekDay System.print("Christmas day, 2021 will fall on %(weekday).") System.print("New year's day, 2022 will also fall on %(weekday).")</lang>
- Output:
Christmas day, 2021 will fall on Saturday. New year's day, 2022 will also fall on Saturday.