MCPcopy Create free account
hub / github.com/eggert/tz / _fmt

Function _fmt

strftime.c:215–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

213}
214
215static char *
216_fmt(const char *format, const struct tm *t, char *pt,
217 const char *ptlim, enum warn *warnp)
218{
219 struct lc_time_T const *Locale = &C_time_locale;
220
221 for ( ; *format; ++format) {
222 if (*format == '%') {
223label:
224 switch (*++format) {
225 default:
226 /* Output unknown conversion specifiers as-is,
227 to aid debugging. This includes '%' at
228 format end. This conforms to C23 section
229 7.29.3.5 paragraph 6, which says behavior
230 is undefined here. */
231 --format;
232 break;
233 case 'A':
234 pt = _add((t->tm_wday < 0 ||
235 t->tm_wday >= DAYSPERWEEK) ?
236 "?" : Locale->weekday[t->tm_wday],
237 pt, ptlim);
238 continue;
239 case 'a':
240 pt = _add((t->tm_wday < 0 ||
241 t->tm_wday >= DAYSPERWEEK) ?
242 "?" : Locale->wday[t->tm_wday],
243 pt, ptlim);
244 continue;
245 case 'B':
246 pt = _add((t->tm_mon < 0 ||
247 t->tm_mon >= MONSPERYEAR) ?
248 "?" : Locale->month[t->tm_mon],
249 pt, ptlim);
250 continue;
251 case 'b':
252 case 'h':
253 pt = _add((t->tm_mon < 0 ||
254 t->tm_mon >= MONSPERYEAR) ?
255 "?" : Locale->mon[t->tm_mon],
256 pt, ptlim);
257 continue;
258 case 'C':
259 /*
260 ** %C used to do a...
261 ** _fmt("%a %b %e %X %Y", t);
262 ** ...whereas now POSIX 1003.2 calls for
263 ** something completely different.
264 ** (ado, 1993-05-24)
265 */
266 pt = _yconv(t->tm_year, TM_YEAR_BASE,
267 true, false, pt, ptlim);
268 continue;
269 case 'c':
270 {
271 enum warn warn2 = IN_SOME;
272

Callers 1

strftimeFunction · 0.85

Calls 5

_addFunction · 0.85
_yconvFunction · 0.85
_convFunction · 0.85
timeoffFunction · 0.85
mktimeFunction · 0.85

Tested by

no test coverage detected