The solar year is 365 days, 5 hours, 48 minutes, 45 seconds, and 138 milliseconds, according to this video. With the current Gregorian calendar, the rules for leap years are as follows:
if year is divisible by 400, LEAP YEAR
else if year is divisible by 100, COMMON YEAR
else if year is divisible by 4, LEAP YEAR
else, COMMON YEAR
Unfortunately, this method is off by one day every 3216 years.
One possible method of reforming the calendar is the following rule:
if year is divisible by 128, COMMON YEAR
else if year is divisible by 4, LEAP YEAR
else, COMMON YEAR
This has the benefit of not requiring us to change our calendars again for another 625,000 years, give or take.
Say the entire world decides that, starting now, we use this system of every fourth year is a leap year except every 128th year, changing our calendars as follows:
YEAR GREGORIAN 128-YEAR
2044 LEAP LEAP
2048 LEAP COMMON
2052 LEAP LEAP
...
2096 LEAP LEAP
2100 COMMON LEAP
2104 LEAP LEAP
...
2296 LEAP LEAP
2300 COMMON LEAP
2304 LEAP COMMON
2308 LEAP LEAP
How would this affect our day of the week algorithms?
The challenge
- Given a date from the year 2000 to the year 100000, find the day of the week under this new calendar.
- Any input and output format is allowed as long as you clearly specify which formats you are using.
- This is code golf so try to make your solutions as golfy as possible!
Test cases
"28 February 2048" -> "Friday"
"March 1, 2048" -> "Sat"
(2100, 2, 29) -> 0 # 0-indexed with Sunday as 0
"2100-02-29" -> 7 # 1-indexed with Sunday as 7
"28 Feb. 2176" -> "Wednesday"
"1-Mar-2176" -> "Th"
"28/02/100000" -> "F" # DD/MM/YYYYYY
"Feb. 29, 100000" -> 6 # 1-indexed with Sunday as 7
"03/01/100000" -> 1 # MM/DD/YYYYYY and 1-indexed with Sunday as 1
Suggestions and feedback on the challenge are welcome. Good luck and good golfing!