|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#include "sflconv.h"
int
conv_str_day (
const char *string)
Converts a string to a day. The string contains a day name in English. Only the first three letters of the name are significant. Returns a value 0..6 for Sunday to Saturday, or -1 if the name is not a valid day.
{
static
char *day_name [] =
{ "sun", "mon", "tue", "wed", "thu", "fri", "sat" };
int
day;
char
day_comp [4];
/* Get up to three letters of day name and convert to lower case */
strncpy (day_comp, string, 3);
day_comp [3] = '\0';
strlwc (day_comp);
/* I don't like magic constants, but "7" is pretty safe for now */
for (day = 0; day < 7; day++)
if (streq (day_name [day], day_comp))
break;
return (day >= 7? -1: day);
}
| | << | < | > | >> |
|