Here is an alternative method based on an algorithm that R. Sivaraman adapted for the Gregorian calendar from an algorithm originally developed by J. Meus for the Julian calendar (see https://en.wikipedia.org/wiki/Computus ).
This seems like a more elegant and intuitive solution than the Gauss algorithm already mentioned. At the very least, it resets a few steps (only 5 points plus JS date methods ) and uses fewer variables (total 4 total plus month, date and year).
function computus( y ) { var date, a, b, c, m, d;
For instance:
console.log( computus( 2016 ) );
source share