The Console That Thought 2010 Was a Leap Year — JavaScript Bug Hunt
Modelled on ApocalyPS3 (1 March 2010): the PlayStation 3's clock firmware treated 2010 as a leap year.
- Language: JavaScript
- Layer: Backend
- Difficulty: Medium
- Concepts: Dates, Leap Years
- Modelled on: PlayStation 3 · 2010
- Visible tests: ordinary leap years are leap; 2010 is not a leap year
- Reward: 50 XP for a complete fix
Briefing
Modelled on ApocalyPS3 (1 March 2010): the PlayStation 3's clock firmware treated 2010 as a leap year. On 1 March the hardware reported a 29 February that did not exist, date validation failed everywhere, and older consoles worldwide could not sign in, play games or use trophies.
clock.js has the same faulty leap-year rule.
Fix isLeapYear so it follows the Gregorian rule.
Bug report
BUG-8001050F · Priority: Critical · Reported by: platform
isLeapYear(year) must implement the Gregorian rule:
- divisible by 4 -> leap
- unless divisible by 100 -> not leap
- unless divisible by 400 -> leap
Observed: 2010 is reported as a leap year, and so is every year ending in 0. 1900 is also wrong in the other direction.
Logs
[rtc] date rolled to 2010-02-29
[rtc] trophy sync failed: invalid timestampThe code as shipped
src/clock/clock.js (editable)
// Gregorian leap-year test.
exports.isLeapYear = function (year) {
// "Every fourth year, and also the round ones" — as shipped.
if (year % 10 === 0) return true;
return year % 4 === 0;
};
exports.daysInFebruary = function (year) {
return exports.isLeapYear(year) ? 29 : 28;
};
Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.