diff options
Diffstat (limited to 'src/strings.c')
-rw-r--r-- | src/strings.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/strings.c b/src/strings.c index 816ddc1..6601a99 100644 --- a/src/strings.c +++ b/src/strings.c @@ -112,3 +112,23 @@ int string_printf(struct string *sb, const char *format, ...) return n; } + +int string_catftime(struct string *sb, const char *format, const struct tm *tm) +{ + int n = 0; + + while (!n) { + string_grow(sb, sb->bufsize * 2); + n = strftime(sb->buf + sb->len, sb->bufsize - sb->len, format, + tm); + } + sb->len += n; + + return n; +} + +int string_strftime(struct string *sb, const char *format, const struct tm *tm) +{ + string_reset(sb); + return string_catftime(sb, format, tm); +} |