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

→‎{{header|Wren}}: Rejigged to deal correctly with 1578.
(Created Nim solution.)
(→‎{{header|Wren}}: Rejigged to deal correctly with 1578.)
Line 1,110:
This uses the same years as the Raku example.
 
The above module uses the Gregorian Proleptic calendar and therefore gives the wrong days of the week for 1578 as the earliest year for the adoption of the Gregorian calendar was 1582 when 10 days (from 5th until 14th October inclusive) were omitted. To get the correct days for 1578 (and agree with the Ruby entry) we therefore need to add 10 days to the Gregorian date.
The actual days for 1578 may have been different as the Gregorian calendar didn't start until 1582.
<syntaxhighlight lang="ecmascript">import "./date" for Date
 
System.print("Days of week per Gregorian Proleptic calendar:")
var years = [1578, 1590, 1642, 1957, 2020, 2021, 2022, 2242, 2245, 2393]
for (year in years) {
var newYear = Date.new(year, 1, 1).weekDay
var xmas = Date.new(year, 12, 25).weekDay
System.print(" In %(year), New year's day is on a %(newYear), and Christmas day on %(xmas).")
}
}</syntaxhighlight>
System.print("\nActual days for 1578 (Julian calendar) were 10 days later:")
System.print(" New Year's day was on %(Date.new(1578, 1, 1).addDays(10).weekDay), and Christmas day on %(Date.new(1578, 12, 25).addDays(10).weekDay).")</syntaxhighlight>
 
{{out}}
<pre>
Days of week per Gregorian Proleptic calendar:
In 1578, New year's day is on a Sunday, and Christmas day on Monday.
In 15901578, New year's day is on a MondaySunday, and Christmas day on TuesdayMonday.
In 16421590, New year's day is on a WednesdayMonday, and Christmas day on ThursdayTuesday.
In 19571642, New year's day is on a TuesdayWednesday, and Christmas day on WednesdayThursday.
In 20201957, New year's day is on a WednesdayTuesday, and Christmas day on FridayWednesday.
In 20212020, New year's day is on a FridayWednesday, and Christmas day on SaturdayFriday.
In 20222021, New year's day is on a SaturdayFriday, and Christmas day on SundaySaturday.
In 22422022, New year's day is on a Saturday, and Christmas day on Sunday.
In 22452242, New year's day is on a WednesdaySaturday, and Christmas day on ThursdaySunday.
In 23932245, New year's day is on a FridayWednesday, and Christmas day on SaturdayThursday.
In 15782393, New year's day is on a SundayFriday, and Christmas day on MondaySaturday.
 
Actual days for 1578 (Julian calendar) were 10 days later:
New Year's day was on Wednesday, and Christmas day on Thursday.
</pre>
 
9,481

edits