Skip to content

Instantly share code, notes, and snippets.

@charliepark
Forked from madrobby/easter.js
Last active December 15, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charliepark/5276891 to your computer and use it in GitHub Desktop.
Save charliepark/5276891 to your computer and use it in GitHub Desktop.
// date of easter, call function with the 4-digit year as argument
//function (a,b,c,d,e,f,g,h,i,j,k,l,m){return b=a%19,c=~~(a/100),d=a%100,e=~~(c/4),f=c%4,g=~~((c+8)/25),h=~~((c-g+1)/3),i=(19*b+c-e-h+15)%30,j=~~(d/4),k=d%4,l=(32+2*f+2*j-i-k)%7,m=~~((b+11*i+22*l)/451),a+"-"+~~((i+l-7*m+114)/31)+"-"+((i+l-7*m+114)%31+1)}
function (y,a,b,c,h,l,n){return a=y%19,b=~~(y/100),c=y%100,h=(19*a+b-~~(b/4)-~~((b-~~((b+8)/25)+1)/3)+15)%30,l=(32+2*b%4+2*~~(c/4)-h-c%4)%7,n=h+l-7*~~((a+11*h+22*l)/451)+114,y+'-'+~~(n/31)+'-'+(n%31+1)}
// f(2013) -> "2013-3-31"
// f(2012) -> "2012-4-8
// f(1775) -> "1775-4-16"
@charliepark
Copy link
Author

To play with after soccer:

function m(a, b){return [~~(a/b), a%b]}

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