in src/dt.c [428:445]
dt_status_t dt_representation_day_of_week(const dt_representation_t *representation, int *day_of_week)
{
int year = 0;
int month = 0;
// TODO: Julian calendar support - now only Gregorian is supported
if (!representation || !day_of_week) {
return DT_INVALID_ARGUMENT;
}
year = (representation->month == 1 || representation->month == 2) ? representation->year - 1 : representation->year;
month = (representation->month == 1 || representation->month == 2) ? representation->month + 12 : representation->month;
// See http://en.wikipedia.org/wiki/Zeller%27s_congruence
*day_of_week = (representation->day + (month + 1) * 26 / 10 + year + year / 4 + 6 * year / 100 + year / 400) % 7;
*day_of_week = *day_of_week == 0 ? 7 : *day_of_week;
return DT_OK;
}