version 1.14, 2005/07/06 06:45:58 |
version 1.15, 2005/08/24 05:19:41 |
|
|
int |
int |
parsemonth(const char *s) |
parsemonth(const char *s) |
{ |
{ |
int v; |
|
char *cp; |
|
struct tm tm; |
struct tm tm; |
|
char *cp; |
|
int v; |
|
|
v = (int)strtol(s, &cp, 10); |
v = (int)strtol(s, &cp, 10); |
if (cp != s) |
if (cp != s) |
return (v); |
; |
if (strptime(s, "%B", &tm) != NULL) |
else if (strptime(s, "%B", &tm) != NULL) |
return (tm.tm_mon + 1); |
v = tm.tm_mon + 1; |
if (strptime(s, "%b", &tm) != NULL) |
else if (strptime(s, "%b", &tm) != NULL) |
return (tm.tm_mon + 1); |
v = tm.tm_mon + 1; |
return (0); |
if (v <= 0 || v > 12) |
|
errx(1, "illegal month value: use 1-12"); |
|
return (v); |
} |
} |