Skip to content

Instantly share code, notes, and snippets.

@jacksteamdev
Last active September 27, 2019 21:57
Show Gist options
  • Save jacksteamdev/9eddfea185a39a92fabf8da496440f39 to your computer and use it in GitHub Desktop.
Save jacksteamdev/9eddfea185a39a92fabf8da496440f39 to your computer and use it in GitHub Desktop.
Calculate numbered day of year
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(); };
@jacksteamdev
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment