24 lines
613 B
C
24 lines
613 B
C
#include "epoch.h"
|
|
#include <strings.h>
|
|
|
|
const char *WeekdayNames[] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday",
|
|
"Tuesday", "Wednesday" };
|
|
const char *WeekdayAbbrs[] = { "Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed" };
|
|
|
|
const char* weekdayName(Weekday day) {
|
|
return WeekdayNames[day];
|
|
}
|
|
|
|
const char* weekdayAbbr(Weekday day) {
|
|
return WeekdayAbbrs[day];
|
|
}
|
|
|
|
int parseWeekday(const char *s) {
|
|
int i;
|
|
for (i = 0; i < 7; i++) {
|
|
if (strncasecmp(s, WeekdayAbbrs[i], 4) == 0 || strncasecmp(s, WeekdayNames[i], 10) == 0) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|