Используйте mktime()
для расчета дня недели.
#include <memory.h>
#include <stdio.h>
#include <time.h>
int main(void) {
const char *p = "2010-03-01";
struct tm t;
memset(&t, 0, sizeof t); // set all fields to 0
if (3 != sscanf(p,"%d-%d-%d", &t.tm_year, &t.tm_mon, &t.tm_mday)) {
; // handle error;
}
// Adjust to struct tm references
t.tm_year -= 1900;
t.tm_mon--;
// Calling mktime will set the value of tm_wday
if (mktime(&t) < 0) {
; // handle error;
}
printf("DOW(%s):%d (0=Sunday, 1=Monday, ...)\n", p, t.tm_wday);
// DOW(2010-03-01):1 (0=Sunday, 1=Monday, ...)
return 0;
}