*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <tzfile.h>
#include <unistd.h>
#include "chpass.h"
#include "pathnames.h"
-static int dmsize[] =
- { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
static char *months[] =
{ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November",
if (tval) {
tp = localtime(&tval);
(void)sprintf(tbuf, "%s %d, %d", months[tp->tm_mon],
- tp->tm_mday, tp->tm_year + TM_YEAR_BASE);
+ tp->tm_mday, tp->tm_year + 1900);
}
else
*tbuf = '\0';
return (tbuf);
-}
+}
int
atot(p, store)
}
if (!(t = strtok(p, " \t")))
goto bad;
- for (mp = months;; ++mp) {
- if (!*mp)
- goto bad;
- if (!strncasecmp(*mp, t, 3)) {
- month = mp - months + 1;
- break;
+ if (isdigit(*t)) {
+ month = atoi(t);
+ } else {
+ for (mp = months;; ++mp) {
+ if (!*mp)
+ goto bad;
+ if (!strncasecmp(*mp, t, 3)) {
+ month = mp - months + 1;
+ break;
+ }
}
}
if (!(t = strtok((char *)NULL, " \t,")) || !isdigit(*t))
if (day < 1 || day > 31 || month < 1 || month > 12 || !year)
goto bad;
if (year < 100)
- year += TM_YEAR_BASE;
- if (year <= EPOCH_YEAR)
+ year += 1900;
+ if (year <= 1970)
bad: return (1);
- tval = isleap(year) && month > 2;
- for (--year; year >= EPOCH_YEAR; --year)
- tval += isleap(year) ?
- DAYSPERLYEAR : DAYSPERNYEAR;
- while (--month)
- tval += dmsize[month];
- tval += day;
- tval = tval * HOURSPERDAY * MINSPERHOUR * SECSPERMIN;
- tval -= lt->tm_gmtoff;
+ lt->tm_year = year - 1900;
+ lt->tm_mon = month - 1;
+ lt->tm_mday = day;
+ lt->tm_hour = 0;
+ lt->tm_min = 0;
+ lt->tm_sec = 0;
+ lt->tm_isdst = -1;
+ if ((tval = mktime(lt)) < 0)
+ return (1);
*store = tval;
return (0);
}
char *p, *sh;
setusershell();
- while (sh = getusershell()) {
+ while ((sh = getusershell())) {
if (!strcmp(name, sh))
return (name);
/* allow just shell name, but use "real" path */