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

Function strftime

strftime.c:184–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182#endif
183
184size_t
185strftime(char *restrict s, size_t maxsize, char const *restrict format,
186 struct tm const *restrict t)
187{
188 char * p;
189 int saved_errno = errno;
190 enum warn warn = IN_NONE;
191
192 tzset();
193 p = _fmt(format, t, s, s + maxsize, &warn);
194 if (DEPRECATE_TWO_DIGIT_YEARS
195 && warn != IN_NONE && getenv(YEAR_2000_NAME)) {
196 fprintf(stderr, "\n");
197 fprintf(stderr, "strftime format \"%s\" ", format);
198 fprintf(stderr, "yields only two digits of years in ");
199 if (warn == IN_SOME)
200 fprintf(stderr, "some locales");
201 else if (warn == IN_THIS)
202 fprintf(stderr, "the current locale");
203 else fprintf(stderr, "all locales");
204 fprintf(stderr, "\n");
205 }
206 if (p == s + maxsize) {
207 errno = ERANGE;
208 return 0;
209 }
210 *p = '\0';
211 errno = saved_errno;
212 return p - s;
213}
214
215static char *
216_fmt(const char *format, const struct tm *t, char *pt,

Callers 3

timeoutFunction · 0.85
strftime_lFunction · 0.85
istrftimeFunction · 0.85

Calls 2

_fmtFunction · 0.85
tzsetFunction · 0.70

Tested by

no test coverage detected