diff options
Diffstat (limited to 'src/time/strftime.c')
| -rw-r--r-- | src/time/strftime.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/time/strftime.c b/src/time/strftime.c index 4d3f78c8..c229e26d 100644 --- a/src/time/strftime.c +++ b/src/time/strftime.c @@ -16,6 +16,10 @@ size_t strftime(char * restrict s, size_t maxsize, const char * restrict format, ASSERT_NONNULL(format); ASSERT_NONNULL(timeptr); + #ifdef _POSIX_SOURCE + tzset(); + #endif + for (i = 0; format[i] != '\0' && converted < maxsize; i++) { if (format[i] != '%') { s[converted++] = format[i]; @@ -48,6 +52,10 @@ size_t strftime(char * restrict s, size_t maxsize, const char * restrict format, sprintf(buf, "%02d", timeptr->tm_mday); break; + case 'e': + sprintf(buf, "%2d", timeptr->tm_mday); + break; + case 'H': sprintf(buf, "%02d", timeptr->tm_hour); break; @@ -68,6 +76,10 @@ size_t strftime(char * restrict s, size_t maxsize, const char * restrict format, sprintf(buf, "%02d", timeptr->tm_min); break; + case 'n': + sprintf(buf, "\n"); + break; + case 'p': sprintf(buf, "%s", lc->lc_time.am_pm[timeptr->tm_hour < 12 ? 0 : 1]); break; @@ -117,8 +129,8 @@ size_t strftime(char * restrict s, size_t maxsize, const char * restrict format, break; default: - sprintf(buf, "UNDEFINED"); /* undefined behavior */ + sprintf(buf, "-strftime(%%%c) is undefined-", format[i]); break; } |
