Skip to content

Instantly share code, notes, and snippets.

@nkostic
Created August 8, 2016 06:51
Show Gist options
  • Save nkostic/9a7d22daeb670ec05dd4be732e27eccb to your computer and use it in GitHub Desktop.
Save nkostic/9a7d22daeb670ec05dd4be732e27eccb to your computer and use it in GitHub Desktop.
Tomohiko Sakamoto's Algorithm
int dow(int y, int m, int d) {
static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
y -= m < 3;
return (y + y/4 - y/100 + y/400 + t[m-1] + d) % 7;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment