Last active
September 27, 2019 21:57
-
-
Save jacksteamdev/9eddfea185a39a92fabf8da496440f39 to your computer and use it in GitHub Desktop.
Calculate numbered day of year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dayNo(y,m,d){ | |
return --m>=0 && m<12 && d>0 && d<29+( | |
4*(y=y&3||!(y%25)&&y&15?0:1)+15662003>>m*2&3 | |
) && m*31-(m>1?(1054267675>>m*3-6&7)-y:0)+d; | |
} | |
Date.prototype.dayNo = function(){ var y=this.getFullYear(), m=this.getMonth(); return m*31-(m>1?(1054267675>>m*3-6&7)-(y&3||!(y%25)&&y&15?0:1):0)+this.getDate(); }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/a/27790471/4842857