6 const char *__langinfo(nl_item);
8 char *strptime(const char *s, const char *f, struct tm *tm)
15 char *strptime(const char *s, const char *f, struct tm *tm)
21 if (isspace(*f)) goto whitespace;
31 item = ABDAY_1 + tm->tm_wday;
34 item = DAY_1 + tm->tm_wday;
38 item = ABMON_1 + tm->tm_mon;
41 item = MON_1 + tm->tm_mon;
47 val = (1900+tm->tm_year) / 100;
66 val = 0; //week_based_year(tm)%100;
71 val = 0; //week_based_year(tm);
81 else if (val > 12) val -= 12;
100 item = tm->tm_hour >= 12 ? PM_STR : AM_STR;
116 val = tm->tm_wday ? tm->tm_wday : 7;
122 // FIXME: week number mess..
135 val = tm->tm_year % 100;
139 val = tm->tm_year + 1900;
143 if (tm->tm_isdst < 0) continue;
144 val = timezone + (tm->tm_isdst) ? __dst_offset : 0;
145 l += snprintf(s+l, n-l, "%+02d%02d", val/60, abs(val%60));
148 if (tm->tm_isdst < 0 || !tzname[0] || !tzname[0][0])
150 l += snprintf(s+l, n-l, "%s", tzname[!!tm->tm_isdst]);
157 if (*s++ != *f) return NULL;
160 while(isspace(*s)) s++;
163 l += snprintf(s+l, n-l, fmt, val);
166 l += snprintf(s+l, n-l, "%s", __langinfo(item));
169 fmt = __langinfo(item);
171 l += strftime(s+l, n-l, fmt, tm);
173 if (l >= n) return 0;