10 char *strptime(const char *s, const char *f, struct tm *tm)
12 int i, w, neg, adj, min, range, *dest;
17 if (isspace(*f)) for (; *s && isspace(*s); s++);
18 else if (*s != *f) return 0;
24 if (isdigit(*f)) w=strtoul(f, (void *)&f, 10);
33 case 'b': case 'B': case 'h':
39 s = strptime(s, nl_langinfo(D_T_FMT), tm);
49 s = strptime(s, "%m/%d/%y", tm);
79 for (; *s && isspace(*s); s++);
82 ex = nl_langinfo(AM_STR);
84 if (!strncasecmp(s, ex, len)) {
88 ex = nl_langinfo(PM_STR);
90 if (!strncasecmp(s, ex, len)) {
97 s = strptime(s, nl_langinfo(T_FMT_AMPM), tm);
101 s = strptime(s, "%H:%M", tm);
110 s = strptime(s, "%H:%M:%S", tm);
123 s = strptime(s, nl_langinfo(D_FMT), tm);
127 s = strptime(s, nl_langinfo(T_FMT), tm);
139 if (*s++ != '%') return 0;
142 if (!isdigit(*s)) return 0;
144 for (i=1; i<=min+range && isdigit(*s); i*=10)
145 *dest = *dest * 10 + *s++ - '0';
146 if (*dest - min >= (unsigned)range) return 0;
148 switch((char *)dest - (char *)tm) {
149 case offsetof(struct tm, tm_yday):
156 else if (*s == '-') neg=1, s++;
157 if (!isdigit(*s)) return 0;
158 for (*dest=i=0; i<w && isdigit(*s); i++)
159 *dest = *dest * 10 + *s++ - '0';
160 if (neg) *dest = -*dest;
164 for (i=2*range-1; i>=0; i--) {
165 ex = nl_langinfo(min+i);
167 if (strncasecmp(s, ex, len)) continue;