- while ((p = strtok (p, " \t")) != NULL) {
- char tzstr[STRING];
- const char *ptz;
-
- switch (count) {
- case 0: /* day of the month */
- if (!isdigit((unsigned char)*p))
- return -1;
- tm.tm_mday = atoi(p);
- if (tm.tm_mday > 31)
- return -1;
- break;
-
- case 1: /* month of the year */
- tm.tm_mon = mutt_check_month(p);
- if (tm.tm_mon < 0)
- return -1;
- break;
-
- case 2: /* year */
- tm.tm_year = atoi(p);
- if (tm.tm_year < 50)
- tm.tm_year += 100;
- else if (tm.tm_year >= 1900)
- tm.tm_year -= 1900;
- break;
-
- case 3: /* time of day */
- tm.tm_hour = strtol(p, &p, 10);
- if (*p++ != ':')
- return -1;
- tm.tm_min = strtol(p, &p, 10);
- if (*p++ == ':') {
- tm.tm_sec = strtol(p, &p, 10);
- } else {
- tm.tm_sec = 0;
- }
- break;
-
- case 4: /* timezone */
- /* sometimes we see things like (MST) or (-0700) so attempt to
- * compensate by uncommenting the string if non-RFC822 compliant
- */
- ptz = uncomment_timezone(tzstr, sizeof(tzstr), p);
-
- if (*ptz == '+' || *ptz == '-') {
- if (isdigit((unsigned char)ptz[1])
- && isdigit((unsigned char)ptz[2])
- && isdigit((unsigned char)ptz[3])
- && isdigit((unsigned char)ptz[4]))
- {
- zoccident = ptz[0] == '-';
- zhours = (ptz[1] - '0') * 10 + (ptz[2] - '0');
- zminutes = (ptz[3] - '0') * 10 + (ptz[4] - '0');
- }
- }
- break;
- }
- count++;
- p = NULL;
- }
-
- if (count < 4) { /* don't check for missing timezone */
- return -1;
- }
-
- if (h) {
- h->zhours = zhours;
- h->zminutes = zminutes;
- h->zoccident = zoccident;
- }
-
- return mutt_mktime(&tm, 0) + (zoccident ? 1 : -1) * (zhours * 3600 + zminutes * 60);