Skip to content

Instantly share code, notes, and snippets.

@metallurgix
Created August 11, 2014 22:12
Show Gist options
  • Save metallurgix/bde7d6c631ae3e8d17a3 to your computer and use it in GitHub Desktop.
Save metallurgix/bde7d6c631ae3e8d17a3 to your computer and use it in GitHub Desktop.
Day of the Week using Date
#include <stdio.h>
char* cal_day(int y, int m, int d)
{
char* days[]={"Sunday","Monday","Tuesday","Wednesday","Thursday", "Friday","Saturday"};
int a=(14-m)/12;
y=y-a;
m=m+12*a-2;
return days[ (d + y + y/4 - y/100 + y/400 + (31*m)/12) % 7];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment